Apache + Tomcat configuration and URL Forwarding

Source: Internet
Author: User
Apache + Tomcat configuration and URL forwarding I. prepare related software a) ApacheHTTPServer2.2 (http://httpd.apache.org/download.cgi) B) Tomcat6.0 (http://tomcat.apache.org/) c) ApacheTomcatConnector... Apache + Tomcat configuration and URL Forwarding
1. prepare relevant software
 
A) Apache HTTP Server 2.2 (http://httpd.apache.org/download.cgi)
 
B) Tomcat 6.0 (http://tomcat.apache.org /)
 
C) Apache Tomcat Connector (http://tomcat.apache.org/connectors-doc/) mod_jk-1.2.31-httpd-2.2.3.so for Apache HTTP Server 2.2
 
II. Apache configuration
 
A) configure Apache + Tomcat
 
I. first, copy the downloaded mod_jk-1.2.31-httpd-2.2.3.so to the modules folder under the Apache HTTP Server installation directory; in the conf directory of Apache HTTP Server, create mod_jk.conf, vhost. conf, workers. properties, uriworkermap. properties (these configuration files can also be directly written in httpd. conf to facilitate management)
 
 
 
Ii. add two lines at the end of httpd. conf.
 
Include conf/mod_jk.conf
 
Include conf/vhost. conf
 
 
 
Iii. modify mod_jk.conf
 
LoadModule jk_module modules/mod_jk-1.2.31-httpd-2.2.3.so
 
JkWorkersFile conf/workers. properties
 
JkMountFile conf/uriworkermap. properties
 
JkLogFile logs/mod_jk.log
 
JkLogLevel error
 
Iv. modify vhost. conf
 
NameVirtualHost *: 80
 

 
DocumentRoot "app directory" # It is best to enclose the specified project location with quotation marks to prevent identification of recording paths.
 
ServerNamelocalhost # "localhost" corresponds to "Host name" in tomcat, and the domain name can be configured
 
Jkmount/servlet/* s1 # all requests that match "/servlet/*" are sent to s1 (tomcat). Therefore, s1 is configured in workers. properties.
 
RewriteEngine On # enable URL Forwarding
 
RewriteRule ^/(. +) $/servlet/UrlRewriteServlet? Name = $1 [PT]
 

 
 
 
V. modify workers. properties
 
Worker. list = s1
 
Worker. s1.port = 8009 # Connector port = "8009" in Tomcat"
 
Worker. s1.host = localhost # IP address of the Tomcat server
 
Worker. s1.type = ajp13 # type
 
Worker. s1.lbfactor = 1 # weight. the higher the value, the more requests are allocated.
 
Worker. list = s2
 
Worker. s2.port = 8009 # Connector port = "8009" in Tomcat"
 
Worker. s2.host = www.abc.com # IP address of the Tomcat server
 
Worker. s2.type = ajp13 # type
 
Worker. s2.lbfactor = 1 # weight. the higher the value, the more requests are allocated.
 
 
 
Vi. modify uriworkermap. properties
 
# All requests are processed by s1 server
 
/* = S1
 
# All requests containing jkstatus are processed by the status server.
 
/Jkstatus = s1
 
All requests ending with ".gif" cannot be processed by the server s1. The following are the same meanings.
 
! /*. Gif = s1
 
! /*. Jpg = s1
 
! /*. Png = s1
 
! /*. Css = s1
 
! /*. Js = s1
 
! /*. Htm = s1
 
! /*. Html = s1
 
 
 
B) configure Apache forwarding
 
I. modify httpd. conf and remove "#"
 
# LoadModule rewrite_module modules/mod_rewrite.so
 
Ii. modify the vhost. conf file and add it under the VirtualHost node.
 
RewriteEngine On # enable forwarding
 
RewriteRule ^/(. +) $/servlet/UrlRewriteServlet? Name = $1 [PT]
 
 
 
III. Tomcat configuration
 
A) configure Connector to correspond to the port in workers. properties.
 

 
 
 
B) configure the Host name to correspond to the ServerName of vhost. conf.
 

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.