Apache + Tomcat integration in Ubuntu _ (mod-JK method)

Source: Internet
Author: User
The integrated centos5 environment is as follows: Apache Source code Pack: httpd-2.2.11.tar.gz http://labs.xiaonei.com/apache-mirror/httpd/httpd-2.2.11.tar.gz
Tomcat binary Code Pack: apache-tomcat-6.0.18.tar.gz binary code package:
Http://apache.mirror.phpchina.com/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.18.tar.gz
JDK binary code package: jdk-6u11-linux-i586-rpm.bin:
Http://java.sun.com/javase/downloads/index.jsp
The installation steps are as follows: Install the GCC compiling environment. Article I have already introduced it. I will not go into details here. Step 1; install JDK # Mount/dev/CDROM/Media/
# Cd/Media/# cp jdk-1_5_0-linux-i586-rpm.bin/usr/local/src/# cd/usr/local/src/# chmod 755 jdk-1_5_0-linux-i586-rpm.bin #. /jdk-1_5_0-linux-i586-rpm.bin Do you agree to the above license terms? [Yes or No] Select Yes. The installation is successful. You can see the/usr/Java/JDK 1.5.0/directory configuration environment variable: CP/etc/profile. Bak.
Vim/etc/profile
Add at the end:
Export java_home =/usr/Java/jdk1.5.0
Export java_bin =/usr/Java/jdk1.5.0/bin
Export Path = $ path: $ java_home/bin
Export classpath =.: $ java_home/lib/dt. jar: $ java_home/lib/tools. Jar
Export java_home java_bin path classpath

Source/etc/profile

Step 2: install Tomcat very simple: # cd/usr/local/src # cp/Media/apache-tomcat-6.0.18.tar.gz/usr/local/src
# Tar xvfz/Media/apache-tomcat-6.0.18.tar.gz

Start Tomcat:/usr/local/tomcat6/bin/startup. Sh
Stop Tomcat:/usr/local/tomcat6/bin/shutdown. Sh

Step 3: install Apache

# Cd/usr/local/src # cp/Media/httpd-2.2.11.tar.gz/usr/local/src # tar xvfz httpd-2.2.11.tar.gz
# Cd httpd-2.2.11/
# Mkdir/usr/local/apache2
#./Configure -- prefix =/usr/local/apache2 -- enable-so
# Make
# Make install
Installation complete!
Integration of tomcat6.0 + apache2.2 started.
The first step is to modify the global configuration file httpd. conf.
CD/usr/local/apache2/CONF/
Cp http. conf HTTP. conf. Bak
Vim HTTP. conf
Servername: 127.0.0.1: 80, Server IP address or domain name

Define index.htm index. jsp in directoryindex
: WQ: Save and exit
Now you can start the apache2.0 server.
Use:/usr/local/apache2/bin/apachectl start
Input: http: // 127.0.0.1/
You will see it works!
This interface is successfully tested.
Start Tomcat with:/usr/local/tomcat6/bin/startup. Sh
Input: http: // 127.0.0.1: 8080/
You will see the Tomcat test page Step 2 is to download and compile the mod_jk.so connection file connecting Tomcat and Apache.
The source code installation package is also downloaded on the http://tomcat.apache.org site: tomcat-connectors-1.2.27-src.tar.gz
First: mkdir/usr/source. Bao
# Cp/Media/tomcat-connectors-1.2.27-src.tar.gz/usr/source. Bao
# Cd/usr/local/src
# Tar xvfz/usr/source. BaO/tomcat-connectors-1.2.27-src.tar.gz
# Cd tomcat-connectors-1.2.27-src/
There is a build.txt inside. Read it carefully.
Then cd native/
# Vim building.txt read it carefully
Then input the following format: #./configure -- With-apxs =/usr/local/apache2/bin/apxs -- With-Java-home =/usr/Java/jdk1.6.0 _ 11
# Make isntall
# Cp APACHE-2.0/mod_jk.so/usr/local/apache2/modules/
This step is important

Step 3: create two configuration files mod_jk.conf and workers. properties under/usr/local/apache2/CONF.
Vim mod_jk.conf
Add the following code:
# Indicates the work required for the mod_jk Module Composition Location of 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 to Tomcat through the ajp13 protocol for Tomcat to process
Jkmount/servlet/* worker1
Jkmount/*. jsp worker1

Vim workers. Properties
Add the following code:
# 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

Configure httpd. conf and make the following changes:
Change Listen 80 to listen 127.0.0.1: 80
Change servername to servername localhost: 80

My webpage is stored in/var/wwwroot, So modify DocumentRoot
Add code:
DocumentRoot "/var/wwwroot"
<Directory "/var/wwwroot">
Options shortdes 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:
Add code:
Loadmodule jk_module modules/mod_jk.so
Include/usr/local/apache2/CONF/mod_jk.conf

Finally, edit the tomcat configuration file server. xml and add the following to the host segment:
<Context Path = "" docbase = "/var/wwwroot"
DEBUG = "0" reloadable = "true" crosscontext = "true"/>

Create a test. jsp under/var/wwwroot, start Apache and tomcat, and access http: // localhost/in a browser. The correct page should be displayed.
 
Example of test. jsp
Hello! The time is <% = new java. util. Date () %>

Enter http: // 127.0.0.1/test. jsp
You will see: Hello! The time is mon Jan 19 19 21:29:38 CST 2009
OK, you have succeeded!

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.