Use mod-jk in linux to integrate apache and tomcat

Source: Internet
Author: User
In linux, use mod-jk to integrate apache and tomcat-Linux Enterprise Application-Linux server application information. The following is a detailed description. See clearly, this is mod-jk, not outdated mod-jk2, the following take ubuntu6.10 version as an example to illustrate the simple installation process.

1. install java or jre and configure the path.

2. install apache.
Sudo apt-get install apache2

3. install tomcat.
To Install Multiple tomcat servers, I pulled xxx.tar.gz from the official website of tomcat and decompressed it, for example, to/usr/local/tomcat.

4. Install mod-jk
Sudo apt-get install libapache2-mod-jk

5. Configure the apache main directory to the tomcat main directory.
Unlike an httpd. conf file in windows, there are a lot of apache configuration files in linux. in/etc/apache2, apache2.conf contains many other files.

Modify the apache directory to direct it to the webapps directory of tomcat. Modify the/etc/apache2/sites-available/default file.
Direct the Directory under DocumentRoot and the Directory below to/usr/local/tomcat/webapps.

6. Use the jsp file as the main file
Edit/etc/apache2/apache2.conf and add an index. jsp

7. Set the link
Create a workers. properties File
Touch/etc/apache2/workers. properties
Edit it and add the following content

Workers. tomcat_home =/usr/lib/tomcat
Workers. java_home =/usr/lib/jdk
Ps =/
Worker. list = worker1

Worker. default. port = 8009
Worker. default. host = localhost
Worker. default. type = ajp13
Worker. default. lbfactor = 1

Among them, worker. tomcat_home is the tomcat installation directory, and workers. java_home is the java directory. If the JAVA_HOME or JRE_HOME line has been set, this line can be omitted.

8. Set mod-jk
Edit/etc/apache2/mod-available/jk. load
Add the following content

LoadModule jk_module/usr/lib/apache2/modules/mod_jk.so

# Where to find workers. properties
JkWorkersFile/etc/apache2/workers. properties

# Where to put jk logs
JkLogFile/var/log/apache2/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 servlet for context/jsp-examples to worker named worker1
JkMount/jsp-examples worker1
# Send JSPs for context/jsp-examples/* to worker named worker1
JkMount/jsp-examples/* worker1
JkUnMount/*. jpg worker1

In total, JkMount and JkUnMount can be configured. The file or file type in the directory of JkMount must be processed by tomcat, while JkUnMount is filtered out, the configuration depends on your web application.

9. Restart tomcat and 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.