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.
# 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.
# Cpapache-tomcat-5.5.12.tar.gz/usr/local/
# Cd/usr/local
# Tar xzvfapache-tomcat-5.5.12.tar.gz
# Ln-sapache-tomcat-5.5.12 Tomcat
4. compile and generate mod_jk.
# Tar xzvfjakarta-tomcat-connectors-1.2.15-src.tar.gz
# Cdjakarta-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:
# Point out the location of the workers. properties file required for mod_jk module work
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 tosend SSL key size,
Jkoptions + forwardkeysize + forwarduricompat-forwarddirectories
# Jkrequestlogformat setthe 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
# Vi workers. Properties
Add the following content:
# Defining a worker namedworker1 and of Type ajp13
Worker. List = worker1
# Set Properties forworker1
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 listen80 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
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:
Loadmodule jk_modulemodules/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 an index. jsp under/var/wwwroot, start Apache and tomcat, and access http: // localhost/in a browser. The correct page is displayed.