Linux--Integration of Web server configuration Apache and Tomcat

Source: Internet
Author: User

First, integrating Apache and Tomcat


Although Tomcat can run independently as a Web server, Tomcat's web capabilities are far from Apache, so in practice, Apache and Tomcat are integrated with the service through the MOD_JK Connector (connectors), Apache handles requests for static pages, and Tomcat handles Servlets and JSP programs.

1. Download MOD_JK

Currently the latest stable version of the MOD_JK connector is 1.2.23, accessed using a Web browser http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/linux/ jk-1.2.23/, click the "mod_jk-1.2.23-apache-2.2.x-linux-i686.so" hyperlink on the page, download the MOD_JK, and the file size is approximately 589kb,7-34.

650) this.width=650; "src=" http://images.51cto.com/files/uploadimg/20081113/134137956.jpg "alt=" 134137956.jpg "/ >

2. Installing and configuring MOD_JK

Copy the mod_jk-1.2.23-apache-2.2.x-linux-i686.so to the/etc/httpd/modules directory and rename it to mod_jk.so.

Create a new subdirectory in the/usr/share/tomcat5/conf directory JK, and create a new file Workers.properties, as follows.

workers.tomcat_home=/usr/share/tomcat5workers.java_home=/usr/lib/jvm/javaps=/worker.list= Ajp13worker.ajp13.port=8009worker.ajp13.host=127.0.0.1worker.ajp13.type=ajp13worker.ajp13.lbfactor=1

Modify the/usr/share/tomcat5/conf/server.xml file to add statements under <engine name= "Catalina" defaulthost= "localhost" > statements < Listener classname= "Org.apache.jk.config. Apacheconfig "modjk="/etc/httpd/modules/mod_jk.so "/>,7-35 shown.

650) this.width=650; "src=" http://images.51cto.com/files/uploadimg/20081113/134309854.jpg "alt=" 134309854.jpg "/ >


Restart the Tomcat service, and the directory/usr/share/tomcat5/conf/auto and file/usr/share/tomcat5/conf/auto/mod_jk.conf will be generated automatically. Copy the file/usr/share/tomcat5/conf/auto/mod_jk.conf to the/USR/SHARE/TOMCAT5/CONF/JK directory and rename it to Mod_jk.conf-auto.

Modify the Mod_jk.conf-auto file and modify the contents as follows.

<ifmodule!mod_jk.c>loadmodule jk_module "/etc/httpd/modules/mod_jk.so" </ifmodule>jkworkersfile "/usr/ Share/tomcat5/conf/jk/workers.properties "Jklogfile"/usr/share/tomcat5/logs/mod_jk.log "JkLogLevel emerg< VirtualHost *:80>servername localhostjkmount/*.jsp ajp13</virtualhost>

3. Configure Tomcat

To achieve Apache and tomcat consolidation, it is necessary to set the home directory for Apache and Tomcat to be consistent. Since Tomcat's default home directory is/var/lib/tomcat5/webapps/root, you should edit Tomcat's master profile/usr/share/tomcat5/conf/server.xml to find the following statement:

After that, add the following statement:


<context path= "" docbase= "/var/www/html" debug= "0"/>

This indicates that the configuration of the Tomcat home directory is shown in/var/www/html/,7-36.

650) this.width=650; "src=" http://images.51cto.com/files/uploadimg/20081113/134543757.jpg "alt=" 134543757.jpg "/ >


4. Configure Apache

Edit the file/etc/httpd/conf/httpd.conf and add the following statement at the end of the file:

Include/usr/share/tomcat5/conf/jk/mod_jk.conf-auto

5. Restarting Apache and Tomcat

Because the configuration files for Apache and Tomcat are modified separately using the MOD_JK connector, you need to restart Apache and Tomcat using the following command.

/ETC/INIT.D/HTTPD restart/etc/init.d/tomcat5 Restart

6. Test Apache and Tomcat integration

Create a file named test.jsp in the home directory/var/www/html/with the following contents:

Hello! The time is <%= new Java.util.Date ()%>

in the client's browser, access the " IP address of the Http://Linux server/test.jsp" If 7-37 is displayed "hello! The time is current "information, which means that Apache and Tomcat integration succeeded.

650) this.width=650; "src=" http://images.51cto.com/files/uploadimg/20081113/134721660.jpg "alt=" 134721660.jpg "/ >

Reference: http://book.51cto.com/art/200811/96928.htm

This article comes from the "Ricky's blog" blog, please be sure to keep this source http://57388.blog.51cto.com/47388/1553681

Linux--Integration of Web server configuration Apache and Tomcat

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.