System environment:
[[email protected] logs] # uname-a # 1 SMP Fri Jan 17:17:51 EST. x86_64 x86_64 x86_64 gnu/linux [[email protected] logs] # Red Hat Enterprise Linux Server release 5.8 (Tikanga)
Software Environment:
Apr-1.5.1.tar.gz
apr-util-1.5.4
Libevent-2.0.22-stable.tar.gz
Pcre-8.36.zip
Httpd-2.2.29.tar.gz
Tomcat-connectors-1.2.40-src.tar.gz
Jdk-7u45-linux-x64.gz
Apache-tomcat-6.0.43.tar.gz
1. Installing Apache
# Compile and install Apr 1.5CD srclib/Apr. /configure--prefix=/usr/local/apr-httpd/makemakeInstall# compile and install Apr-util 1.5CD. /apr-util./configure--prefix=/usr/local/apr-util-httpd/--with-apr=/usr/local/apr-httpd/Makemake Install# Configure httpdCD. /.. /. /configure--with-apr=/usr/local/apr-httpd/--with-apr-util=/usr/local/apr-util-httpd/--prefix=/usr/local/ apache2.2
Make && make install
2, install Tomcat, before I have described how to install Tomcat, here do not introduce, please look ahead of my blog
3. Compile and build mod_jk
[[email protected] data]#tar xzvf tomcat-connectors-1.2.40-src.tar.gz[[email protected] data]#CD TOMCAT-CONNECTORS-1.2.40-SRC[[email protected] tomcat-connectors-1.2.40-src]#lsconf Docs howto-RELEASE.txt jkstatus LICENSE native NOTICE README.txt Support Tools Xdocs[[email protected] Tomcat-CONNECTORS-1.2.40-SRC]#CD native/[[email protected] native]#lsaclocal.m4 buildconf.sh config.log Configure IIS makefile.am README.txt todo.txtapache-1.3 BUILDING.txt config.nice configure.ac libtool Makefile.inchScriptsapache-2.0Common config.status docs Makefile Netscape Status.txt[[email protected] native]#./configure--with Apxs=/usr/local/apache2.2/bin/apxs[[email protected] native]# Make
4. Create two files under apache2.2 conf file:
mod_jk.conf workers.properties
[[email protected] native] # cd/usr/local/apache2.2/conf/ [[email protected] conf] # lsextra httpd.conf Magic mime.types mod_jk.conf original workers.properties
To edit the mod_jk.conf configuration file:
[[email protected] conf]#Cat mod_jk.confjkworkersfile/usr/local/apache2.2/conf/workers.properties#Where to put JK logsjklogfile/usr/local/apache2.2/logs/Mod_jk.log#Set the JK log level [Debug/error/info]Jkloglevel Info#Select the log formatJklogstampformat"[%a%b%d%h:%m:%s%Y]"#jkoptions indicate to send SSL KEY SIZE,Jkoptions +forwardkeysize +forwarduricompat-forwarddirectories#Jkrequestlogformat Set the request formatJkrequestlogformat"%w%V%T"#send all servlet and JSP requests through the AJP13 protocol to Tomcat for Tomcat to handlejkmount/servlet/*Worker1jkmount/*.jsp Worker1
Edit workers.properties:
Note: Worker1 is the name of Tomcat, and so will be the same name when you configure Tomcat
[[email protected] Conf]# cat Workers.properties # defining a worker Named Worker1 and of type ajp13 worker.list=# Set properties for Worker1 worker.worker1.type=ajp13 worker.worker1.host =localhost worker.worker1.port =8009worker.worker1.lbfactor =50 worker.worker1.cachesize =10 worker.worker1.cache_timeout =600 worker.worker1.socket_keepalive = 1 worker.worker1.socket_timeout =300
5, reconfigure httpd.conf, make the following modifications:
Modify Listen 80 to Listen 127.0.0.1:80
Modify ServerName to ServerName localhost:80
Add index.jsp
My page under/var/www/html in DirectoryIndex, so modify DocumentRoot
ListenServerName localhost:"/var/www/html""/var/ www/html"> allowoverride None Order allow,deny from all xbithackon </directory><ifmodule dir_module> directoryindex index.html index.jsp </IfModule># Add a statement to load the MOD_JK module LoadModulejk_module modules//usr/local/ Apache2.2/conf/mod_jk.conf
6. Modify the Tomcat server.xml configuration file:
# in the host segment, add the Context segment, temperament docBase for the web directory <context path="" docbase= "/var/www/html " debug="0" reloadable="true" crosscontext= "true"/>
Add Engine:
<engine name="Catalina" defaulthost="localhost" jvmroute ="worker1">
7. Restart Apache and Tomcat servers
#开启tomcat服务 [[email protected] conf]#. /bin/catalina.sh startusing catalina_base:/usr/local/tomcat6.0using catalina_home:/usr/local/tomcat6.0Using Catalina_tmpdir:/usr/local/tomcat6.0/tempusing jre_home:/usr/local/jdk1.7using CLASSPATH:/usr/local/tomcat 6.0/bin/bootstrap.jar[[email protected] conf]# PS aux|grep java root 6159 156 4.3 519068 45072 pts/1 Sl 10:36 0:01/usr/local/jdk1.7/bin/java-djava.util.logging.config.file=/usr/local/tomcat6.0/conf/ logging.properties-djava.util.logging.manager=org.apache.juli.classloaderlogmanager-djava.endorsed.dirs=/usr/ local/tomcat6.0/endorsed-classpath/usr/local/tomcat6.0/bin/bootstrap.jar-dcatalina.base=/usr/local/tomcat6.0- Dcatalina.home=/usr/local/tomcat6.0-djava.io.tmpdir=/usr/local/tomcat6.0/temp Org.apache.catalina.startup.Bootstrap startroot 6170 0.0 0.0 61176 724 pts/1 r+ 10:36 0:00 grep java
#开启apache服务: Apachectl-k Start
8. Verification:
[[email protected] conf] # curl-i http://127.0.0.1/index.jsp http/1.1 Apr 03:29:39 gmtserver:apache/2.2.29 (Unix) mod_jk/1.2.40 Set-cookie: Jsessionid=1b7e68b32f64a807ac695f13f2851e58.worker1; path=/content-length:65content-type:text/html
For example, we can see that the Apache version number is exposed, so we need to hide the Apache version number.
To change the configuration file httpd.conf, add the following two lines of configuration:
Serversignature OFF
Servertokens Prod
Serversignature appears at the bottom of the page that Apache produces like 404 pages, directory listings, and so on
The Servertokens directory is used to determine what information Apache will populate in the header of the server HTTP response packet
Restart Apache Service
Hide Tomcat version number information:
To the Apache-tomcat installation directory of the Lib subfolder, find Catalina.jar This package, and to unzip Catalina.jar
After extracting the progress to the org/catalina/apache/util/directory, edit the Serverinfo.properties
Vim/path/tomcat/lib/org/apache/catalina/util/serverinfo.properties
Original configuration: Server.info=apache Tomcat/6.0.43server.number=6.0.43.0server.built=nov 10:04:27 UTC Modified: server.info= Apache tomcat/xserver.number=xserver.built=x
- After modifying the configuration file, re-compress the Catalina.jar file:
CP Catalina.jar catalina.jar.datrm-f catalina.jarzip-r Catalina.jar meta-inf
The display page of Tomcat error is displayed:
- HTTP Status 404-/index.jsp
type Status Report
message /index.jsp
Description The requested resource is not available.
Apache tomcat/x
Apache+tomcat Integration