Objective: Integration of Apache and Tomcat enables both Java and PHP projects to share 80 ports, eliminating the need to add a port number in the address bar when accessing a website.
Environmental Description: Linux CentOS 32 bits Apache 2.2.2 Tomcat 7.0.37
Preparation: Download mod_jk so http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/ Open the link to find the appropriate file to download and rename it mod_jk.so
Modify Apache related files 1. Upload mod_ES31en. so to /modules 2. Create a new file mod_jk.conf under /apache/conf #Load mod_jk module LoadModule jk_module modules/mod_jk.so #Where to find workers.properties JkWorkersFile conf/workers.properties #Where to put jk logs JklogFile logs/mod_jk.log #Set the jk log level[debug/error/info] JkLogLevel info #Select the log format JkLogStampFormat ”[%a %b %d %H:%M:%S %Y] ” #JkOptions indicate to send SSL KEY SIZE, JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories #JkRequestLogFormat set the request format JkRequestLogFormat “%w %V %T” #Send servlet for context /examples to worker named ajp13 JkMount /servlet/* ajp13 #Send all files under MyProject for to worker named ajp13 JKMount /MyProject ajp13
3. Create new file workers.properties in /apache/conf worker.list=ajp13 worker.ajp13.port=8009 worker.ajp13.host=localhost worker.ajp13.type=ajp13 worker.ajp13.lbfactor=1
4. Modification /conf/ ES95en. conf Listen 80 change to Listen Your IP:80 ServerName localhost:80
Add Include conf/ mod_ES108en.conf to the last line Find DocumentRoot and remember its value, which will be useful later. I was/www/apache/htdocs
5, add < VirtualHost > node
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
ServerName www.sample.cn/m
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /MyProject http://www.sample.cn/MyProject/pages/login.jsp
ProxyPassReverse /MyProject http://www.sample.cn/MyProject/pages/login.jsp
</VirtualHost>
[Note:] The name of the scarlet letter part must be 1, that is, it must be 1 with the project name under tomcat Modify Tomcat related documents 1. Add ES128en. xml to tomcat My directory: / opt tomcat/conf/Catalina/localhost New ROOT xml
<?xml version='1.0' encoding='utf-8'?>
<Context displayName="Welcome to Tomcat" docBase="" path="" debug="0"></Context>
2. Modification /conf/ ES143en. xml I. Change the default port number (or not, default 1 is 8080) < Connector port=“9090” protocol=“HTTP/1.1” connectionTimeout=“20000” redirectPort=“8443” / > II. Check the AJP port number (8009 cannot be modified, uncomment this sentence if it has been commented out)
< Connector port=“8009” protocol=“AJP/1.3” redirectPort=“8443” / > Check III. < HOST > node < Host name=“localhost” appBase=“webapps” unpackWARs=“true” autoDeploy=“true” >
— — — — — — — — — — — — — — — — — — — — — — — friendship reminder — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — - At this point, you can access the java project through the domain name/project name /, but please note that the last ”/” can’t be less! If you don’t want users to add /, see Adding backslashes after the site directory. ----------------------------------------------------------------------------------------------