Simple integration of Apache and Tomcat in Linux

Source: Internet
Author: User
Simple method for integrating Apache and Tomcat in Linux: 1. prepare and download the required files. It is assumed that JDK has been installed and configured accurately. Download the required file from the Apache official website: add the statement for loading mod_jk: You can also write the preceding statement to the APACHE configuration file to change HTTPD. CONF file, as follows: then, modify workers. pro

1. prepare and download the required files. It is assumed that JDK has been installed and configured accurately.

Download the required files from the Apache official website:

Httpd-2.2.4.tar.gz
Apache-tomcat-6.0.13.tar.gz
Tomcat-connectors-1.2.23-src.tar.gz

2. install Apache.

# Tar xzvf httpd-2.2.4.tar.gz
# Cd httpd-2.2.4
#./Configure -- prefix =/usr/local/apache
-- With-mpm = worker -- enable-module = so
-- Enable-MoD-shared = all
-- Enable-ssl = shared
-- Enable-deflate = shared
# Make
# Make install

3. install Tomcat.

# Cp apache-tomcat-6.0.13.tar.gz/usr/local/
# Cd/usr/local/
# Tar xzvf apache-tomcat-6.0.13.tar.gz
# Ln-s apache-tomcat-6.0.13 tomcat (this step can be omitted)

4. Compile the native mod_jk.

# Tar xzvf tomcat-connectors-1.2.23-src.tar.gz
# Cd tomcat-connectors-1.2.23-src/native
#./Configure -- with-apxs =/usr/local/apache/bin/apxs
# Make
# Cp./apache-2.0/mod_jk.so/usr/local/apache/modules/

5. configuration.

Create two configuration files mod_jk.conf (or written to the apache Main configuration file) and workers. properties under/usr/local/APACHE/conf.
# Vi mod_jk.conf

Add the following content:

# Indicates the position of the workers. properties file required for mod_jk module work
JkWorkersFile/usr/local/apache/conf/workers. properties
# Where to put jk logs
JkLogFile/usr/local/apache/logs/mod_jk.log
# 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 \"
# Send all servlet and jsp requests to Tomcat through the ajp13 protocol for Tomcat to handle
JkMount/servlet/* lb-server
JkMount/*. jsp lb-server
# Vi workers. properties

Add the following content:

# Defining a worker named worker1 and of type ajp13
Worker. list = lb-server
# Set properties for worker1
Worker. lb-server.type = ajp13
Worker. lb-server.host = localhost
Worker. lb-server.port = 8009
Worker. lb-server.lbfactor = 50
Worker. lb-server.cachesize = 10
Worker. lb-server.cache_timeout = 600
Worker. lb-server.socket_keepalive = 1
Worker. lb-server.socket_timeout = 300

Configure httpd. conf and make the following corrections:

Modify Listen 80 to Listen 127.0.0.1: 80.
Change ServerName to ServerName LocalHost: 80
Add index. jsp to DirectoryIndex
My webpage is under/var/www, so modify DocumentRoot
DocumentRoot \ "/var/www \"

Options shortdes FollowSymLinks
AllowOverride None
Order deny, allow
Allow from all
XBitHack on


Order deny, allow

Deny from all


Add the statement about loading mod_jk:

LoadModule jk_module modules/mod_jk.so
Include/usr/local/apache/conf/mod_jk.conf

Finally, compile the Tomcat configuration file server. xml. in the HOST segment, enter:

Create an index. jsp under/var/wwwroot, start Apache and Tomcat, and visit http: // localhost/in a browser. the correct page should be displayed.


The above can also be written to the APACHE configuration file, that is, you can change the HTTPD. CONF file, as follows:

LoadModule jk_module modules/mod_jk.so
# Configure mod_jk
JkWorkersFile conf/workers. properties
JkLogFile logs/mod_jk.log
JkLogLevel info
JkMount/*. jsp lb-server

Modify workers. properties, add the required WORKLIST, and upload the page to the specified home directory of the website. start TOMCAT and view the page in APACHE.

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.