Integration of apache2.2 and tomcat6.x + mod_jk

Source: Internet
Author: User
Installation environment:

Centos 5.6, Apache httpd 2.2 tomcat6 mod_jk 1.2.23

Software Download:

Tomcat: http://labs.renren.com/apache-mirror/tomcat/tomcat-6/v6.0.33/bin/apache-tomcat-6.0.33.tar.gz

Httpd: http://mirror.bjtu.edu.cn/apache//httpd/httpd-2.2.19.tar.gz

Mod_jk: http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/linux/jk-1.2.23/mod_jk-1.2.23-apache-2.2.x-linux-i686.so

Installation Steps: 1. Create the workers. properties file and add the following content

Enter the httpd installation directory, for example,/etc/httpd/, and then enter the conf directory below to create the workers. properties file and add the following # Content

######################################## #################

Worker. List = loadbalancer, status, T1

# T1

# Tomcat Port

Worker. t1.port = 8009

# Tomcat host

Worker. t1.host = 127.0.0.1

# Forwarding request protocol type

Worker. t1.type = ajp13

# Load Balancing Weight

Worker. t1.lbfactor = 1

# T2

Worker. loadbalancer. type = LB

Worker. loadbalancer. balance_workers = T1

# Listen to the status to view the working status of each worker

Worker. Status. type = Status

 

######################################## ###################

 

To deploy multiple Tomcat servers, modify the preceding Configuration:

Worker. List = loadbalancer, status, T1, T2

# T1

# Specified Communication Port

Worker. t1.port = 8009

# Specify the address of the host where the Tomcat service is located

Worker. t1.host = 127.0.0.1

# Communication protocol

Worker. t1.type = ajp13

Worker. t1.lbfactor = 1

 

# T2

Worker. t2.port = 8009

Worker. t2.host = 192.168.0.32

Worker. t2.type = ajp13

Worker. t2.lbfactor = 1

Worker. loadbalancer. type = LB

Worker. loadbalancer. balance_workers = T1, T2

Worker. Status. type = Status

 

2. Configure forwarding rules to create the uriworkermap. properties file and add the following content:

Go to the httpd installation directory, for example,/etc/httpd/, and enter the conf directory below to create

Uriworkermap. properties file and add the following # Content

######################################## #######################

# View the worker status through http: IP/status

/Status = Status

# Send all requests to loadbalancer for processing

/* = Loadbalancer

# Filter requests that do not require Tomcat processing

! /*. Gif = loadbalancer

! /*. Jpg = loadbalancer

! /*. PNG = loadbalancer

! /*. CSS = loadbalancer

! /*. Js = loadbalancer

! /*. Htm = loadbalancer

! /*. Html = loadbalancer

 

######################################## ########################

3. Configure the httpd. conf file in the conf directory.

Go to the httpd installation directory, for example,/etc/httpd/, and enter the conf directory below to edit httpd. conf. Add the following italic content to the end of the file:

# Define Directory Access Permissions

<Directory "/usr/local/Apache-Tomcat-6.0.33/webroot/Sims">

AllowOverride none

Options none

Order allow, deny

Allow from all

Directoryindex index.html

</Directory>

Note: Create the webroot directory in the Tomcat directory (for example,/usr/local/Apache-Tomcat-6.0.33/). The release package (Sims. War) will be placed here.

# Load the mod_jk plug-in

Loadmodule jk_module modules/mod_jk.so

Note: Rename the downloaded mod_jk plug-in file mod_jk.so to the/etc/httpd/modules/directory.

 

# Load the tomcat configuration file

Jkworkersfile CONF/workers. Properties

Note: workers. properties is created in the preceding step.

 

# Specify the log file and Log Level

Jklogfile logs/mod_jk.log

Jkloglevel info

# Configuring a VM

<Virtualhost *: 80>

DocumentRoot "/usr/local/Apache-Tomcat-6.0.33/webroot/Sims"

Servername localhost

Directoryindex index.html

Errorlog "logs/sims_error_log"

Jkmountfile CONF/uriworkermap. Properties

Customlog "logs/sims_access_log" common

</Virtualhost>

Note: DocumentRoot is the Sims Application Deployment directory. If some directories do not exist, create them.

Configure the Local Machine for the servername server domain name.

Directoryindex application homepage.

Errorlog specifies the location of the error log file.

Jkmountfile: Configure forwarding rules to distribute requests that access this domain name.

Customlog access logging file

4. tomcat configuration

1) Tomcat Directory: for example,/usr/local/Apache-Tomcat-6.0.33/the actual installation directory shall prevail.

2) create a webroot folder under the Tomcat root directory and copy the corresponding Sims. War package to this directory.

3) create a new Sims folder under webroot and run the unzip-D Sims. War Command to decompress the war to Sims. Note: The unzip command:-D is followed by the Directory to be decompressed. If the unzip command is not supported, decompress Sims. War on windwo and upload it to the webroot directory.

4) Go To The conf directory under the Tomcat directory and find and edit the server. xml file. Add the following content to the

<Context Path = "" docbase = "/usr/local/Apache-Tomcat-6.0.32/webroot/Sims" DEBUG = "0" reloadable = "true"/>

Note: the/usr/local/Apache-Tomcat-6.0.32/webroot/SIMS directory must exist.

you only need to restart the Tomcat service each time you update the service.

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.