Apache Tomcat integration tutorial

Source: Internet
Author: User
Tags apache tomcat

Apache Tomcat integration tutorial

 

1. Main software preparation

Download JDK, tomcat, Apache server, and Tomcat Connector

In this tutorial, jdk1.6, Tomcat 6.0.13, apache_2.2.4-win32-x86-no_ssl, mod_jk-apache-2.2.4.so

 

2. install and configure JDK and tomcat, and install Apache

There are many tutorials online, mainly to set some environment variables

In this tutorial

Java_home = D:/program files/Java/jdk1.6.0

Tomcat_home = D:/program files/Apache Software Foundation/tomcat 6.0

Apache_home = D:/program files/Apache Software Foundation/apache2.2

Replace % xxx_home % with the installation path later.

 

3. Copy Tomcat Connector to the % apache_home %/models/directory.

On the apacehe homepage, find Tomcat ors

Http://tomcat.apache.org/download-connectors.cgi)

The latest is the mod_jk-apache-2.2.4.so, and then copy it to the % apache_home %/models/directory

4. Create the workers. properties file in the % apache_home %/CONF/directory.

Content:

# The content of workers. propertie is as follows:

Worker. List = loadbalancer, server105, server106

# Define the first node...

Worker. server105.port = 8009

Worker. server105.host = 127.0.0.1

Worker. server105.type = ajp13

Worker. server105.lbfactor = 1

 

# Worker. server105.local _ worker = 1

Worker. server105.cachesize = 100

 

# Define the 2nd node...

Worker. server106.port = 8009

Worker. server106.host = 127.0.0.1

Worker. server106.type = ajp13

Worker. server106.lbfactor = 1

 

# Worker. server106.local _ worker = 1

Worker. server106.cachesize = 100

 

# Now we define the load-balancing behaviour

Worker. loadbalancer. type = LB

Worker. loadbalancer. balanced_workers = server105, server106

Worker. loadbalancer. sticky_session = 1

 

 

5. Modify the % apache_home %/CONF/httpd. conf file.

1) Find the <ifmodule dir_module> label

<Ifmodule dir_module>

Directoryindex index.html

</Ifmodule>

Change directoryindex index.htm to directoryindex index.html index.htm index. jsp.

 

2) Find the DocumentRoot variable

#

# DocumentRoot: the directory out of which you will serve your

# Events. By default, all requests are taken from this directory,

# Symbolic links and aliases may be used to point to other locations.

#

DocumentRoot "D:/program files/Apache Software Foundation/apache2.2/htdocs"

 

Change DocumentRoot to the default root directory of Tomcat, that is, % atat_home %/webapps/root.

X is modified as follows:

DocumentRoot "D:/program files/Apache Software Foundation/tomcat 6.0/webapps/root"

Note: The URL path format is used here. "/" is used to replace "/" in the system file path "/"

3) Find the <directory> label. You can find a lot. Note the annotation above the label

"Change the value to the DocumentRoot variable value"

#

# This shoshould be changed to whatever you set DocumentRoot.

#

<Directory "D:/program files/Apache Software Foundation/apache2.2/htdocs">

The modified result is as follows:

<Directory "D:/program files/Apache Software Foundation/tomcat 6.0/webapps/root">

Note: The URL path format is used here. "/" is used to replace "/" in the system file path "/"

4)

Add the following content at the end of httpd. conf to complete task allocation with Tomcat.

########################### The following content is added ####### #####################

Loadmodule jk_module modules/mod_jk-apache-2.2.4.so # The name of the connector downloaded must be the same

[Add to the position of the loadmodule. Otherwise, an error may occur.!]

Jkworkersfile CONF/workers. properties # The attribute file name must be consistent with that created in step 3.

Jklogfile logs/mod_jk.log # Save the log to the mod_jk.log file.

# Set the jk log level [debug/error/info]

Jkloglevel info

# Select the log format

Jklogstampformat "[% A % B % d % H: % m: % S % Y]"

# Jkoptions indicate to send SSL key size,

Jkoptions + forwardkeysize + forwarduricompat-forwarddirectories

# Jkrequestlogformat set the request format

Jkrequestlogformat "% w % v % t"

Jkmount/* loadbalancer

 

Jkmount/xajob/* loadbalancer

 

# Apache will serve the static picture.

# The following command means that all images will be parsed by Apache

Jkunmount/*. jpg loadbalancer

Jkunmount/*. gif loadbalancer

Jkunmount/*. SWF loadbalancer

Jkunmount/*. BMP loadbalancer

Jkunmount/*. PNG loadbalancer

 

 

6. Restart Tomcat and Apache server

If http: // localhost: 8080 and http: // localhost are used, Tomcat is displayed.

The default page. Congratulations, the configuration is successful.

Note: In this tutorial, Tomcat uses the default port 8080, and Apache uses port 80 for system service installation. If you use different ports, add your own port number after the path according to the actual situation.

 

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.