Integration of Apache2.2 and Tomcat6 in Ubuntu12.04

Source: Internet
Author: User
Anyone who has experience building servers knows that, if J2EE is used, integrating Tomcat and Apache has the following advantages: 1. using Apache for load balancing and fault tolerance; 2, apache focuses on static Web page parsing, while tomcat focuses on dynamic web page parsing, which improves server efficiency. 3. Applications can be upgraded seamlessly. I recently used Ubuntu12.04 as a server (in principle, I should not use the latest version but a stable version). I have read many books on apache and tomcat integration,

Anyone who has experience building servers knows that, if J2EE is used, integrating Tomcat and Apache has the following advantages: 1. using Apache for load balancing and fault tolerance; 2, apache focuses on static Web page parsing, while tomcat focuses on dynamic web page parsing, which improves server efficiency. 3. Applications can be upgraded seamlessly.

I recently used Ubuntu12.04 as a server (in principle, I should not use the latest version but a stable version). I have read many books on apache and tomcat integration, finally, I found that the content in the book is a little different for ubuntu12.04. The following is a summary of the experience for your reference:

Install apache and tomcat and install mod_jk (sudo apt-get install libapache2-mod-jk.

  I. AJP Connector

Tomcat 6 provides the AJP Connector implementation for the AJP protocol as a java class, which is included in the Tomcat release version. First, you should define the connector in $ CATALINA_HOME/server. xml:

<-- Define an AJP1.3 Connector on port 8009 -->

Generally, you can remove the comments and add them without them.

  2. Compile the workers. properties File

Workers. the properties file is used to define some variables that are connected to tomcat, you do not need to create it yourself, you have created a file in the/etc/libapache2-mod-jk/directory when installing the libapache2-mod-jk package, you can modify it directly:

$ Sudo nano/etc/libapache2-mod-jk/workers. properties

Modify the corresponding row as follows:

Worker. list = myworker
Worker. myworker. port = 8009
Worker. myworker. host = localhost // if you are on another server, change it to the corresponding host ip address.
Worker. myworker. type = ajp13
Worker. myworker. lbfactory = 1
Worker. loadbalancer. type = lb
Worker. loadbalancer. balance_workers = myworker

  3. Configure/etc/apache2/apache2.conf. (We recommend that you create the mod_jk file in the/etc/apache2/conf. d/directory, and write the same content in this step)

# Tell JK where to find workers. properties
JkWorkersFile/etc/libapache2-mod-jk/workers. properties # restart apache if allow once prompt appears, www.linuxidc.com please comment out this line

# Define JK log location
JkLogFile/var/log/apache2/mod_jk.log

# Set the JK log level (debug/error/info)
JkLogLevel info

Set Log format
JkLogStampFormat "[% a % B % d % H: % M: % S % Y]"

# JK options
JkOption + ForwardKeySize + ForwardURICompat-ForwardDirectories

# Set Request format
JkRequestLogFormat "% w % V % T"

  4. Configure Virtual Hosts

$ Sudo nano/etc/apache2/sites-available/default

Add the following code at the end:

.....


JkMount/*. jsp myworker # submit all jsp page requests to myworker for processing.
JkUnMount/*. php myworker # All php page requests are not handled by myworker.

  5. Notes:

Many books have said that you want to add mod_jk.so to the module Directory of apache, But if you install the libapache2-mod-jk through sudo apt-get install successfully, it is not necessary, and also automatically help you write LoadModule ~

Related Article

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.