A simple way to integrate Apache with Tomcat under Linux

Source: Internet
Author: User
Tags tomcat linux

1, prepare, download the required documents. This assumes that you have installed the JDK correctly.

Download the required files to the Apache official website:

httpd-2.2.0.tar.gz
apache-tomcat-5.5.12.tar.gz
jakarta-tomcat-connectors-1.2.15-src.tar.gz

where httpd and jakarta-tomcat-connectors for the source package, Apache-tomcat for the binary package.

2, install Apache.

# tar XZVF httpd-2.2.0.tar.gz

# CD httpd-2.2.0

#./configure--prefix=/usr/local/apache2--enable-so

# make

# make Install

3, install Tomcat.

# CP apache-tomcat-5.5.12.tar.gz/usr/local/

# cd/usr/local

# tar XZVF apache-tomcat-5.5.12.tar.gz

# ln-s apache-tomcat-5.5.12 Tomcat

4. Compile and generate MOD_JK.

# tar XZVF jakarta-tomcat-connectors-1.2.15-src.tar.gz

# CD Jakarta-tomcat-connectors-1.2.15-src/jk/native

#./configure--with-apxs=/usr/local/apache2/bin/apxs

# make

# CP./apache-2.0/mod_jk.so/usr/local/apache2/modules/

5, configuration.

Create two profiles mod_jk.conf and workers.properties below/usr/local/apache2/conf/.

# VI Mod_jk.conf

Add the following:

# indicates the location of the working files required for MOD_JK module work workers.properties

Jkworkersfile/usr/local/apache2/conf/workers.properties

# Where to put JK logs

Jklogfile/usr/local/apache2/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 through the AJP13 protocol to Tomcat for Tomcat to process

jkmount/servlet/* Worker1

Jkmount/*.jsp Worker1

# VI Workers.properties

Add the following:

# Defining a worker named Worker1 and of type ajp13

Worker.list=worker1

# Set Properties for Worker1

Worker.worker1.type=ajp13

Worker.worker1.host=localhost

worker.worker1.port=8009

Worker.worker1.lbfactor=50

worker.worker1.cachesize=10

worker.worker1.cache_timeout=600

Worker.worker1.socket_keepalive=1

worker.worker1.socket_timeout=300

Then configure HTTPD.CONF to make the following modifications:

Modify Listen 80 to Listen 127.0.0.1:80

Modify the ServerName to ServerName localhost:80

Add index.jsp to DirectoryIndex

My page is placed under/var/wwwroot, so I want to modify the DocumentRoot

DocumentRoot "/var/wwwroot"
<Directory "/var/wwwroot">
  Options Includes FollowSymLinks
  AllowOverride None
  Order deny,allow
  Allow from all
  XBitHack on
</Directory>
<Directory "/var/wwwroot/WEB-INF">  
  Order deny,allow
  Deny from all
</Directory>

Add the statements about loading MOD_JK:

LoadModule Jk_module modules/mod_jk.so

Include/usr/local/apache2/conf/mod_jk.conf

Finally, edit Tomcat's profile server.xml and add in the host segment:

<Context path="" docBase="/var/wwwroot" debug="0" reloadable="true" crossContext="true"/>

Create a index.jsp under/var/wwwroot, start Apache and Tomcat, and use the browser to access http://localhost/, you should be able to see the correct page.

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.