[Reprinted] A Simple Method for integrating Apache and tomcat in Linux

Source: Internet
Author: User

Source: http://www.linuxsir.org/bbs/showthread.php? T = 236915

1. Prepare and download the required files. It is assumed that JDK has been correctly installed and configured.
Download the required files from 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
Httpd and Jakarta-Tomcat-connectors are source code packages and APACHE-Tomcat are Binary packages.
2. install Apache.

Code:

# 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.

Code:

# 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.

Code:

# 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 configuration files mod_jk.conf and workers. properties under/usr/local/apache2/CONF.
# Vi mod_jk.conf
Add the following content:

Code:

# Specify the workers file required for mod_jk module work. properties location jkworkersfile/usr/local/apache2/CONF/workers. properties # where to put JK logsjklogfile/usr/local/apache2/logs/mod_jk.log # Set the jk log level [debug/error/info] jkloglevel info # select the log formatjklogstampformat "[% 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, let Tomcat handle jkmount/servlet/* worker1jkmount /*. JSP worker1

# Vi workers. Properties
Add the following content:

Code:

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

Configure httpd. conf and make the following changes:
Change Listen 80 to listen 127.0.0.1: 80
Change servername to servername localhost: 80
Add index. jsp to directoryindex
My webpage is stored in/var/wwwroot, So modify DocumentRoot

Code:

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 statement about loading mod_jk:

Code:

LoadModule jk_module modules/mod_jk.soInclude /usr/local/apache2/conf/mod_jk.conf

Finally, edit the tomcat configuration file server. xml and add the following to the host segment:

Code:

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

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

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.