apache2.4 TOMCAT6 Cluster AJP configuration method

Source: Internet
Author: User

Environment: Apache2.4 (192.168.1.15:1102) installation path: E:\Platform\Apache24

Node 1 Tomcat6 (192.168.1.15:8080 ajp:8010)

Node 2 Tomcat6 (192.168.1.15:8081 ajp:8011)


Install the Apache service and install it as a Windows service.

CMD command line method:

"E:\Platform\Apache24\bin\httpd.exe"-K install-n Apache

The following Apache is the service name of the Windows system after installation and can be changed arbitrarily.


1, import the required OS files:

LoadModule Proxy_module modules/mod_proxy.so
LoadModule Proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule Rewrite_module modules/mod_rewrite.so
LoadModule Proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule Proxy_connect_module modules/mod_proxy_connect.so
LoadModule Proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule Proxy_http_module modules/mod_proxy_http.so
LoadModule Slotmem_shm_module modules/mod_slotmem_shm.so
LoadModule Speling_module modules/mod_speling.so
LoadModule Ssl_module modules/mod_ssl.so
LoadModule Lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
LoadModule Jk_module modules/mod_jk.so


2, Apache Port and other information:

To change the apache24\conf\httpd.conf file:

Listen 1102

ServerRoot "E:/platform/apache24"

ServerName 192.168.1.15:1102

scriptalias/cgi-bin/"e:/platform/apache24/cgi-bin/"


<directory "E:/platform/apache24/cgi-bin" >
AllowOverride None
Options None
Require all granted
</Directory>


Crucially, to import the configuration of the virtual host into the file to release:

Include conf/extra/httpd-vhosts.conf


Last side, add:

Proxyrequests off
<proxy balancer://cluster>
Balancermember ajp://192.168.1.15:8011 loadfactor=1 route=jvm1
Balancermember ajp://192.168.1.15:8010 loadfactor=1 route=jvm2
</proxy>


At this point, the httpd.conf configuration is complete.


Configuration key points:

1, Tomcat's port number:

<proxy balancer://cluster>
balancermemberajp://192.168.1.15:8011 loadfactor=1 ROUTE=JVM1
balancermemberajp://192.168.1.15:8010 loadfactor=1 route=jvm2
</proxy>

The port number in these two, must be AJP ports, not HTTP port, be sure to note.


3, the configuration of the virtual host

The configuration file for the virtual host is the configuration file that is released above. Apache24\conf\extra\httpd-vhosts.conf


<virtualhost 192.168.1.15:1102>
ServerAdmin 111@163.com
ServerName localhost
Serveralias localhost
Proxypass/balancer://cluster/stickysession=jsessionid Nofailover=on
proxypassreverse/balancer://cluster/
ErrorLog "Logs/localhost.log"
Customlog "Logs/localhost_access.log" common
</VirtualHost>


The above instructions, there are many online, can be looked for. ServerName, configuration into localhost, and some said need to register in the system's hosts file, I did not register, is also available, because I do not use the way domain name. If it is the way to use the domain name, then you need to do the conversion in the hosts file.


4, Tomcat node configuration.

This is very simple, if local, ensure that each port number does not repeat. If it is a different machine, it can be the same.

Because we adopt the AJP way, the AJP port number is very important. When Apache forwards, it is forwarded through this port.

Tomcat configuration, first, is the configuration of the HTTP,AJP port, all configured in Server.xml.

In addition, you need

<engine name= "Catalina" defaulthost= "localhost" jvmroute= "jvm1" >

The node name jvm1 configured in the httpd.conf appended to this.

<cluster classname= "Org.apache.catalina.ha.tcp.SimpleTcpCluster"/> This also want to let go, is used for session copy.


Finally, in the application web.xml, you need to add a cluster configuration.

Finally add:

<distributable/>

This should be added to the front of </web-app> yo.


Up to this point, the two-node cluster is configured to complete.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.