For integration of Apache httpserver and tomcat, see the previous article:
Http://blog.csdn.net/supercrsky/article/details/8295023
I.ConfigurationTomcat
Here we use two Tomcat servers and copy one directly in the installed directory, named tomcat2.
# Cp-r/opt/tomcat/tomcat2
Go to the tomcat2 directory, edit CONF/server. XML, and modify the default port.
# Vi CONF/server. xml
1. Set
<Server port="8005" shutdown="SHUTDOWN">
Change
<Server port="9005" shutdown="SHUTDOWN">
2. Set
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
Modify:
<Connector port="9090" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="9443" />
3. Find:
<Engine name="Catalina" defaultHost="localhost">
Change
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">
Change the content in tomcat2
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat2">
4. Find
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
Change
<Connector port="9009" protocol="AJP/1.3" redirectPort="8443" />
5. Find
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" />
Uncomment.
2. Configure HTTP Server
1. Check whether HTTPS is enabled and make sure the following sentence has been commented out.
#Include conf/extra/httpd-ssl.conf
2. Find the virtualhost node we added at the bottom of the file and change it:
<VirtualHost *>DocumentRoot /usr/local/www/<Directory "/usr/local/www/composite"> AllowOverride None Order allow,deny Allow from all</Directory><Directory "/usr/local/www/composite/WEB-INF"> Order deny,allow Deny from all</Directory>ServerAdmin localhostDocumentRoot /usr/local/www/ServerName localhostDirectoryIndex index.html index.htm index.jsp index.actionErrorLog logs/shsc-error_log.txtCustomLog logs/shsc-access_log.txt commonJkMount /*WEB-INF controllerJkMount /*j_spring_security_check controllerJkMount /*.action controllerJkMount /servlet/* controllerJkMount /*.jsp controllerJkMount /*.do controller</VirtualHost>
4. Edit CONF/workers. properties:
worker.list = controller#tomcat1worker.tomcat1.port=8009 worker.tomcat1.host=localhostworker.tomcat1.type=ajp13worker.tomcat1.lbfactor=1#tomcat2worker.tomcat2.port=9009 worker.tomcat2.host=localhostworker.tomcat2.type=ajp13worker.tomcat2.lbfactor=1#========controller========worker.controller.type=lbworker.controller.balance_workers=tomcat1,tomcat2worker.lbcontroller.sticky_session=0worker.controller.sticky_session_force=trueworker.connection_pool_size=3000worker.connection_pool_minsize=50worker.connection_pool_timeout=50000
This sentence is very importantWorker. List = ControllerIf httpd is not added, it cannot be started. The following error occurs when you view the log:
Cocould not find a worker for worker name = Controller
For a horizontal cluster, change worker. atat1.host or worker. tomcat2.host to the IP address of the corresponding machine.
3. Deploy and Test
Make sure that the WEB-INF/Web. xml file in the project is added before </Web-app>
<Distributable/>
Deploy the project to/usr/local/WWW,/opt/tomcat/webapps,/opt/tomcat2/webapps
Enable Tomcat 1 and tomcat 2 respectively.
#/Opt/tomcat/bin/startup. Sh
#/Opt/tomcat2/bin/startup. Sh
#/Usr/local/httpd2.2/bin/apachectl start
Start two Firefox and access our project respectively. Here is: http: // localhost/Composite
Observe the logs corresponding to/opt/tomcat/logs/AND/opt/tomcat2/logs,
We found that tomcat1 and tomcat2 have processed a client request respectively.