您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 销售管理 > Apache+Tomcat配置及URL转发
Apache+Tomcat配置及URL转发一、准备相关软件a)ApacheHTTPServer2.2()b)Tomcat6.0()c)ApacheTomcatConnector()mod_jk-1.2.31-httpd-2.2.3.so对应ApacheHTTPServer2.2的版本二、Apache配置a)配置Apache+Tomcati.首先将下载的mod_jk-1.2.31-httpd-2.2.3.so复制到ApacheHTTPServer安装目录下的modules文件夹下;在ApacheHTTPServer的conf目录下新建mod_jk.conf,vhost.conf,workers.properties,uriworkermap.properties(这些配置文件也可以直接写在httpd.conf中,单独提出方便管理)ii.在httpd.conf最后添加两行includeconf/mod_jk.confincludeconf/vhost.confiii.修改mod_jk.confLoadModulejk_modulemodules/mod_jk-1.2.31-httpd-2.2.3.soJkWorkersFileconf/workers.propertiesJkMountFileconf/uriworkermap.propertiesJkLogFilelogs/mod_jk.logJkLogLevelerroriv.修改vhost.confNameVirtualHost*:80VirtualHost*:80DocumentRootapp目录#指定项目位置最好带引号防止无法识别录路径,可以不要ServerNamelocalhost#localhost将与tomcat中的Hostname对应,可以配置域名Jkmount/servlet/*s1#所有匹配/servlet/*的请求都交给s1(tomcat)处,理,s1配置在workers.properties中RewriteEngineOn#开启URL转发RewriteRule^/(.+)$/servlet/UrlRewriteServlet?name=$1[PT]/VirtualHostv.修改workers.propertiesworker.list=s1worker.s1.port=8009#对应Tomcat中的Connectorport=8009worker.s1.host=localhost#Tomcat所在服务器IPworker.s1.type=ajp13#类型worker.s1.lbfactor=1#权重,值越高,分得的请求越多worker.list=s2worker.s2.port=8009#对应Tomcat中的Connectorport=8009worker.s2.host=所在服务器IPworker.s2.type=ajp13#类型worker.s2.lbfactor=1#权重,值越高,分得的请求越多vi.修改uriworkermap.properties#所有请求都由s1这个server处理/*=s1#所有包含jkstatus请求的都由status这个server处理/jkstatus=s1#所有以.gif结尾的请求都不由s1这个server处理,以下几个都是一样的意思!/*.gif=s1!/*.jpg=s1!/*.png=s1!/*.css=s1!/*.js=s1!/*.htm=s1!/*.html=s1b)配置Apache转发i.修改httpd.conf,去掉“#”#LoadModulerewrite_modulemodules/mod_rewrite.soii.修改vhost.conf文件,在VirtualHost节点下添加RewriteEngineOn#打开转发RewriteRule^/(.+)$/servlet/UrlRewriteServlet?name=$1[PT]三、Tomcat配置a)配置Connector与workers.properties中的port对应Connectorport=8009protocol=AJP/1.3redirectPort=8443/b)配置Hostname与vhost.conf的ServerName对应Hostname=localhostappBase=webapps
本文标题:Apache+Tomcat配置及URL转发
链接地址:https://www.777doc.com/doc-4627365 .html