The following installation method is for Windows platform
One, download apache2.4 and tomcat8.0 installation package
- Apache2.4:http://www.apachelounge.com/download/ (Windows platform may need to be installed : Visual C + + Redistributable For Visual Studio RC)
- Tomcat:http://tomcat.apache.org/download-80.cgi
Second, test start (extract an Apache and two tomcat)
Whether Apache and Tomcat were successfully launched separately. Apache's conf/httpd.conf needs to be configured as follows:
1. Modify the root path of ServerRoot Apache
2, open servername, as follows
3, modify the DocumentRoot
4, modify the Portal file configuration: DirectoryIndex (can be modified, not modified)
5, set the Serverscript directory
After Apache starts successfully, enter http://localhost in the browser address bar after the following page:
tomcat8.0 requires JDK7.0 or more support, each Tomcat Start.bat needs to be set to Java_home, CLASSPATH, Catalina_home (the current Tomcat Catalina_home). You can directly modify Start.bat as follows:
Third, change the Apache configuration
1. (Apache conf/httpd.conf) Modify httpd.conf Add module
#---------------------LoadModule start------------------------LoadModule lbmethod_byrequests_module modules/mod_ Lbmethod_byrequests.soloadmodule proxy_module modules/mod_proxy.soloadmodule proxy_ajp_module modules/mod_proxy_ Ajp.soloadmodule rewrite_module modules/mod_rewrite.soloadmodule proxy_balancer_module modules/mod_proxy_ Balancer.soloadmodule proxy_connect_module modules/mod_proxy_connect.soloadmodule proxy_ftp_module modules/mod_ Proxy_ftp.soloadmodule proxy_http_module modules/mod_proxy_http.soloadmodule slotmem_shm_module modules/mod_ Slotmem_shm.soloadmodule speling_module modules/mod_speling.soloadmodule ssl_module modules/mod_ssl.so#----------- -----------LoadModule End-------------------------
2. Remove the comment tag for include conf/extra/httpd-vhosts.conf #
3. Add reverse proxy at the end of file
Proxyrequests Off <proxy balancer://cluster> balancermember ajp://127.0.0.1:8009 loadfactor=1 route=jvm1 balancermember ajp://127.0.0.1:9009 loadfactor=1 route=jvm2 </proxy>
4, modify the conf/extra/httpd-vhosts.conf
Comment out all the dummy-host, add the following content
<virtualhost *:80> ServerAdmin [email protected] ServerName localhost serveralias localhost Proxypass/balancer://cluster/stickysession=jsessionid Nofailover=on proxypassreverse/balancer://cluster/ errorlog "Logs/lbtest-error.log" Customlog "Logs/lbtest-access.log" Common </VirtualHost>
Four, change the Tomcat configuration: tomcat1 use 8080, tomcat2 use 9080
1, change tomcat2:<server port= "8005" shutdown= "Shutdown" > modified to 9005
2, modify <connector port= "8080" protocol= "http/1.1"
connectiontimeout= "20000"
redirectport= port in "8443"/> is 9080
3, modify <connector port= "8009" protocol= "ajp/1.3" redirectport= "8443"/> Modified to 9009
4, modify <engine name= "Catalina" defaulthost= "localhost" > at the end add jvmroute= "jvm2". At the same time, modify the TOMCAT1 label as Jvmroute= "JVM1" (the label is not open by default)
TOMCAT1:
TOMCAT2:
5, modify the TOMCAT1, Tomcat2 server.xml <cluster classname= "Org.apache.catalina.ha.tcp.SimpleTcpCluster"/> Changed to
<cluster classname= "Org.apache.catalina.ha.tcp.SimpleTcpCluster" > <valve classname= " Org.apache.catalina.ha.tcp.ReplicationValve "filter=". *\.gif;. *\.js;. *\.jpg;. *\.png;. *\.htm;. *\.html;. *\.css;. *\.txt; " /></cluster>
6. Deploy test project to TOMCAT1 and TOMCAT2 below, then start TOMCAT1, TOMCAT2, Apache respectively. Then enter http://localhost/test/test.jsp in the Address bar to test.
Test item: http://download.csdn.net/detail/wuxian90/8847303
Note:
Apache may have some errors when booting up, common errors listed below (after correcting the error, you need to clear the log under logs, reboot)
- ah01177:failed to Lookup provider ' SHM ' for ' slotmem ': Is Mod_slotmem_shm loaded. let go mod_slotmem_shm .
- Ah02432:cannot Find LB method:byrequests. let go lbmethod_byrequests_module .
- ah00098:pid File E: / Java / Servers / 03_cluster / 00-apache24 /logs/httpd.pid overwritten--unclean shutdown of previous Apache run. Delete the file under logs/.
apache2.4+tomcat8.0 cluster installation