apache2.2+tomcat6.0实战

  • 格式:doc
  • 大小:71.50 KB
  • 文档页数:7

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

(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_PA TH),3,Tomcat6安装目录:C:\Tomcat 6.0 端口为81安装中需要指定Tomcat使用的端口号、服务器管理员登录用户名和密码。

前面的可以按照默认的来,用户名和密码要牢记。

三,测试。

1,验证JDK安装状态打开cmd命令窗口,输入java2,开启apache2.2服务http://127.0.0.1/3,开启tomcat服务http://127.0.0.1:81/四,配置apache(整个过程其实就是让apache的httpd.conf文件调用mod_jk.conf,mod_jk.conf调用workers.properties)。

1,打开C:\AppServ\Apache2.2\conf\httpd.conf文件在最后的LoadModule 行(安ctrl+f查找LoadModule)下面加上LoadModule jk_module modules/mod_jk.so2,在配置文件的最下面加上Include conf/mod_jk.conf3,在C:\AppServ\Apache2.2\modules文件夹下加上mod_jk-apache-2.2.4.so (要和apache版本相同,或则尽量选择版本接近,这点很重要)文件并改名为mod_jk.so4,在C:\AppServ\Apache2.2\conf文件夹下加上mod_jk.conf(主要定义mod_jk模块的位置以及mod_jk模块的连接日志设置,还有定义worker.properties 文件的位置。

)文件文件内容如下:JkWorkersFile C:\AppServ\Apache2.2\conf\workers.propertiesJkLogFile C:\AppServ\Apache2.2\logs/mod_jk.logJkLogLevel infoJkLogStampFormat "[%a %b %d %H:%M:%S %Y]"JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories JkRequestLogFormat "%w %V %T"JkMount /*.PictureCheckCode s1JkMount /servlet/* s1JkMount /*.jsp s1JkMount /*.action s15,在C:\AppServ\Apache2.2\conf文件夹下加上workers.properties(定义worker的参数,主要是连接tomcat主机的地址和端口信息。

如果Tomcat与apache不在同一台机器上,或者需要做多台机器上tomcat的负载均衡只需要更改workers.properties 文件中的相应定义即可。

)文件文件内容如下:worker.list= s1worker.s1.port=8009worker.s1.host=localhostworker.s1.type=ajp13worker.DLOG4J.type=lbworker.retries=3worker.DLOG4J.balanced_workers=s1worker.DLOG4J.sticky_session=1worker.status.type=status6,修改Apache的文档主目录。

把DocumentRoot 和<Directory >节点上的值修改为"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"<Directory "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# /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,denyAllow from all</Directory>7, 修改C:\AppServ\Apache2.2\conf\httpd.conf文件的配置:<IfModule dir_module>DirectoryIndex index.html index.jsp index.php index.htm</IfModule>五,配置tomcat。

1,修改Tomcat的文档主目录。

打开C:\Tomcat 6.0\conf\ server.xml文件把<Host 节点上的appBase值修改为E:\wwwroot:<Host name="localhost" appBase="E:\wwwroot"unpackW ARs="true" autoDeploy="true"xmlV alidation="false" xmlNamespaceA ware="false">六,整合实战。

1,在E:\wwwroot下放入项目2,重新启动apache2.2和tomcat服务器3,测试项目意事项及出现的问题:端口号被占用实战设置:参考:/Apache/ApacheMenu/index.html1,重定向:httpd.conf配置:##########重定向########################################## 第二种方法:# RedirectMatch ^/$ http://127.0.0.1/finance/Main.action###########重定向########################################RewriteEngine onRewriteRule ^/$ /finance/Main.action [R]2,限制文件访问:httpd.conf配置:#########禁止访问finance项目下的WEB-ING文件夹下的文件##############<Directory ~ "E:/wwwroot/finance/WEB-INF">Order allow,denyDeny from all</Directory>3,一般情况下,不应该使用.htaccess文件禁用自动扫描.htaccess文件,httpd.conf配置:<Directory "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# /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,denyAllow from all</Directory>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.htmlErrorDocument 404 /404.htmlErrorDocument 403 /403.htmlErrorDocument 503 /503.html#ErrorDocument 404 "/cgi-bin/missing_handler.pl"#ErrorDocument 402 /subscription_info.html5,tomcat网页错误控制跳转,C:\tomcat6\conf\web.xml配置:<error-page><error-code>404</error-code><location>/404.html</location></error-page><error-page><error-code>403</error-code><location>/403.html</location></error-page><error-page><error-code>401</error-code><location>/401.html</location></error-page><error-page><error-code>503</error-code><location>/503.html</location></error-page>优化参考:1,TOMCA T+apache 2000万访问量的实现:/content/09/1010/15/186523_7068797.shtml2,修改tomcat内存大小:/2010/0327/21418.php3,tomcat优化配置:/nic/Programing/systemservice/32984.htm4,apache+tomcat/blog/294089我是初学者!很需要经验指导和错误纠正等等学习,有的忘告知,大家一起学习进步!!!邮箱:shangchenbs@。