apache2.2 tomcat6.0实战

以下红色皆为测试参数,可自行定义:一,系统。 .............................................................................

以下红色皆为测试参数,可自行定义:

一,系统。 ........................................................................................................ 1

二,安装软件..................................................................................................... 1

三, 测试 . ......................................................................................................... 1

四,配置apache ................................................................................................. 2

五,配置tomcat ................................................................................................. 4

六,整合实战。 ................................................................................................. 4

意事项及出现的问题:....................................................................................... 4

实战设置: ........................................................................................................ 5

一,系统。

Window XP(2003)

二,安装软件(安装路径不要有空格) 。

1,appserv-win32-2.5.10.exe

安装目录:C:AppServ 端口80

安装过程中需要指定服务器所在的DNS 域名、服务器DNS 名称、管理员邮箱,以及服务器启动参数。没有域名可以指定DNS 域名和服务器DNS 名称为localhost 。实际工作中,DNS 域名为所购域名的后半部分,服务器DNS 名称即为所购域名。如果服务器没有提供邮件服务,管理员邮箱可以任意指定。

,2,JDK6

安装目录:C:Java 配置好相应的环境变量(JA V A_HOME,PA TH ,CLASS_PATH ) ,3,Tomcat6

安装目录:C:Tomcat 6.0 端口为81

安装中需要指定Tomcat 使用的端口号、服务器管理员登录用户名和密码。前面的可以按照默认的来,用户名和密码要牢记。

三, 测试。

1,验证JDK 安装状态

打开cmd 命令窗口,输入java

2,开启apache2.2服务 http://127.0.0.1/

3,开启tomcat 服务

,

四,配置apache (整个过程其实就是让apache 的httpd.conf 文件调用mod_jk.conf,mod_jk.conf调用workers.properties ) 。

1,打开C:AppServApache2.2confhttpd.conf文件

在最后的LoadModule 行(安ctrl f查找LoadModule )下面加上

LoadModule jk_module modules/mod_jk.so

2,在配置文件的最下面加上

Include conf/mod_jk.conf

3,在C:AppServApache2.2modules文件夹下加上

mod_jk-apache-2.2.4.so (要和apache 版本相同,或则尽量选择版本接近,这点很重要) 文件 并改名为mod_jk.so

4,在C:AppServApache2.2conf文件夹下加上

mod_jk.conf

(主要定义mod_jk模块的位置以及mod_jk模块的连接日志设置,还有定义worker.properties 文件的位置。)

文件 文件内容如下:

JkWorkersFile C:AppServApache2.2confworkers.properties

JkLogFile C:AppServApache2.2logs/mod_jk.log

JkLogLevel info

JkLogStampFormat "[a b d H:M:S Y]"

JkOptions ForwardKeySize ForwardURICompat -ForwardDirectories

JkRequestLogFormat "w V T"

JkMount /*.PictureCheckCode s1

JkMount /servlet/* s1

JkMount /*.jsp s1

JkMount /*.action s1

5,在C:AppServApache2.2conf文件夹下加上

workers.properties

(定义worker 的参数,主要是连接tomcat 主机的地址和端口信息。如果Tomcat 与apache 不在同一台机器上,或者需要做多台机器上tomcat 的负载均衡只需要更改workers.properties 文件中的相应定义即可。)

文件 文件内容如下:

worker.list= s1

worker.s1.port=8009

worker.s1.host=localhost

,

worker.s1.type=ajp13

worker.DLOG4J.type=lb

worker.retries=3

worker.DLOG4J.balanced_workers=s1

worker.DLOG4J.sticky_session=1

worker.status.type=status

6,修改Apache 的文档主目录。把DocumentRoot 和 节点上的值 修改为"E:wwwroot":

#

# DocumentRoot: The directory out of which you will serve your

# documents. By default, all requests are taken from this directory, but

# symbolic links and aliases may be used to point to other locations.

#

DocumentRoot "E:wwwroot"

#

# Possible values for the Options directive are "None", "All",

# or any combination of:

# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you.

#

# The Options directive is both complicated and important. Please see

# http://httpd.apache.org/docs/2.2/mod/core.html#options

# for more information.

#

Options Indexes FollowSymLinks MultiViews ExecCGI

#

# AllowOverride controls what directives may be placed in .htaccess files.

# It can be "All", "None", or any combination of the keywords:

# Options FileInfo AuthConfig Limit

#

AllowOverride All

#

# Controls who can get stuff from this server.

#

Order allow,deny

Allow from all

,

7, 修改C:AppServApache2.2confhttpd.conf文件的配置:

DirectoryIndex index.html index.jsp index.php index.htm

五,配置tomcat 。

1,修改Tomcat 的文档主目录。打开C:Tomcat 6.0conf server.xml文件 把

unpackW ARs="true" autoDeploy="true"

xmlV alidation="false" xmlNamespaceAware="false">

六,整合实战。

1,在 E:wwwroot下放入项目

2,重新启动apache2.2和tomcat 服务器

3,测试项目

意事项及出现的问题:

端口号被占用

,

实战设置:

参考:http://lamp.linux.gov.cn/Apache/ApacheMenu/index.html

1,重定向:httpd.conf 配置:

##########重定向########################################

#

# 第二种方法:

# RedirectMatch ^/$ http://127.0.0.1/finance/Main.action

#

##########重定向########################################

RewriteEngine on

RewriteRule ^/$ /finance/Main.action [R]

2,限制文件访问:httpd.conf 配置:

#########禁止访问finance 项目下的WEB-ING 文件夹下的文件##############

Order allow,deny

Deny from all

3,一般情况下,不应该使用.htaccess 文件

禁用自动扫描.htaccess 文件,httpd.conf 配置:

#

# Possible values for the Options directive are "None", "All",

# or any combination of:

# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews #

# Note that "MultiViews" must be named *explicitly* --- "Options All"

# doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.2/mod/core.html#options

# for more information.

#

Options Indexes FollowSymLinks MultiViews ExecCGI

#

# AllowOverride controls what directives may be placed in .htaccess files.

# It can be "All", "None", or any combination of the keywords:

,

# Options FileInfo AuthConfig Limit

#

AllowOverride None

#

# Controls who can get stuff from this server.

#

Order allow,deny

Allow from all

4,apache 网页错误控制跳转,httpd.conf 配置:

#

# Customizable error responses come in three flavors:

# 1) plain text 2) local redirects 3) external redirects

#

# Some examples:

#ErrorDocument 500 "The server made a boo boo."

ErrorDocument 401 /401.html

ErrorDocument 404 /404.html

ErrorDocument 403 /403.html

ErrorDocument 503 /503.html

#ErrorDocument 404 "/cgi-bin/missing_handler.pl"

#ErrorDocument 402

5,tomcat 网页错误控制跳转,C:tomcat6confweb.xml配置:

404

/404.html

403

/403.html

401

/401.html

503

/503.html

,

优化参考:

1,TOMCA T apache 2000万访问量的实现: http://www.360doc.com/content/09/1010/15/186523_7068797.shtml

2,修改tomcat 内存大小: http://edu.codepub.com/2010/0327/21418.php

3,tomcat 优化配置:

4,apache tomcat

我是初学者!很需要经验指导和错误纠正等等学习,有的忘告知,大家一起学习进步!!! 邮箱:shangchenbs@qq.com

标签: