整合篇 方法一 #wget #tar zxvf tomcat-* #cd tomcat-*/native #./configure --with-apxs=/usr/local/apache/bin/apxs #make && make install 到apache的modules下面看看有没有mod_jk.so模块
配置apache支持jk模块
#vim /usr/local/apache/conf/httpd.conf
添加 index.jsp
DirectoryIndex index.jsp index.html
LoadModule jk_module modules/mod_jk.so… Include conf/extra/mod_jk.conf #vim /usr/local/apache/conf/extra/mod_jk.conf JkWorkersFile conf/extra/workers.properties JkLogFile logs/mod_jk.log JkShmFile logs/jk-runtime-status JkLogLevel info JkLogStampFormat "[%a %b %d %H:%M:%S %Y] " JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories JkRequestLogFormat "%w %V %T" #Sample JkMounts. Replace these with the paths you would #like to mount from your JSP server. #syntax: JkMount ${URL_DIR}/*.jsp worker_name JkMount /images/avatar/* worker1 JkMount /*.jsp worker1 JkMount /*.page worker1 JkMount /*.cic worker1 JkMount /func/* worker1 JkMount /assets/* worker1 JkMount /remote/* worker1 JkMount /services/* worker1 JkMount /homebase/* worker1 JkMount /skin/* worker1 JkMount /error/* worker1 JkMount /lib/* worker1 JkMount /protected/* worker1 JkMount /rounded/* worker1 JkMount /FormOverLogin* worker1 JkMount /fckeditor/editor/filemanager/connectors/* worker1 JkMount /upload/image/* worker1 #vim /usr/local/apache/conf/extra/workers.properties worker.list=worker1 worker.worker1.port=8009 worker.worker1.host=localhost worker.worker1.type=ajp13 worker.woker1.lbfactor=1 修改tomcat跟apache知道让web指向同一个目录 #vim /usr/src/tomcat/conf/server.xml <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Context path="/" docBase="/usr/local/apache/htdocs" debug="0" workDir="/tmp" reloadable="false"/> #/usr/local/apache/bin/apachectl restart # /usr/local/tomcat/bin/shutdown.sh #/usr/local/tomcat/bin/startup.sh 测试页面 #vim /usr/local/apache/htdocs/index.jsp <% out.print("jsp页面测试"); % 访问 localhost 完毕! 整合篇,方法二。 在 /usr/local/apache/conf/httpd.conf 末尾加入 : <Proxy balancer://localCluster> BalancerMember ajp://localhost:8009 </Proxy> RewriteEngine On ProxyPreserveHost On RewriteRule ^/$ balancer://localCluster/ [P,L,NC] RewriteRule ^/(.*)$ balancer://localCluster/$1 [P,L,NC] 修改tomcat跟apache知道让web指向同一个目录 #vim /usr/local/tomcat/conf/server.xml <Host name="localhost" appBase="/usr/local/apache/htdocs" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Context path="/" docBase="." debug="0" workDir="/tmp" reloadable="false"/> 新建测试页 vi /usr/local/apache/htdocs/index.jsp <html> <body> <h1>JSP Test Page</h1> <%=new java.util.Date() %> </body> </html> 重启apache和tomcat, 然后直接访问