前面已经做好了apache+jdk+mysql+php+tomcat的安装。下面就开始作tomcat7.0+apache2.2的整合了
第一步是下载和编译mod_jk.so 这个连接tomcat和apache.的连接文件。
照样也是在http://tomcat.apache.org 这个网站上下载的源代码安装包:tomcat-connectors-1.2.27-src.tar.gz
首先: mkdir /usr/source.bao
#cp /media/sf_share/tomcat-connectors-1.2.36-src.tar.gz /usr/local
#cd /usr/local
#tar -zxvf /usr/local/tomcat-connectors-1.2.36-src.tar.gz
#cd tomcat-connectors-1.2.36-src
照样也是在http://tomcat.apache.org 这个网站上下载的源代码安装包:tomcat-connectors-1.2.27-src.tar.gz
首先: mkdir /usr/source.bao
#cp /media/sf_share/tomcat-connectors-1.2.36-src.tar.gz /usr/local
#cd /usr/local
#tar -zxvf /usr/local/tomcat-connectors-1.2.36-src.tar.gz
#cd tomcat-connectors-1.2.36-src
注意里面有一个BUILD.txt 仔细阅读它
进入目录 native
进入目录 native
安装:
# ./configure --with-apxs=/usr/local/apache/bin/apxs --with-java-home=/usr/lib/jvm/java-7-sun
#make
#make isntall
#cp apache-2.0/mod_jk.so /usr/local/apache/modules/
第二步:在/usr/local/apache/conf/下面建立两个配置文件mod_jk.conf和workers.properties。
vim mod_jk.conf
添加以下代码:
# 指出mod_jk模块工作所需要的工作文件workers.properties的位置
JkWorkersFile /usr/local/apache/conf/workers.properties
# Where to put jk logs
JkLogFile /usr/local/apache/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"
# 将所有servlet 和jsp请求通过ajp13的协议送给Tomcat,让Tomcat来处理
JkMount /servlet/* worker1
JkMount /*.jsp worker1
vim workers.properties
添加以下代码:
# Defining a worker named worker1 and of type ajp13
worker.list=worker1
# Set properties for worker1
worker.worker1.type=ajp13
worker.worker1.host=127.0.0.1
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
再配置httpd.conf,作以下修改:
将Listen 80 修改为 Listen 127.0.0.1:80
将ServerName 修改为 ServerName LocalHost:80
我的网页放在/var/wwwroot下,所以要修改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>
增加关于加载mod_jk的语句:
添加代码:
LoadModule jk_module modules/mod_jk.so
Include /usr/local/apache2/conf/mod_jk.conf
最后编辑Tomcat的配置文件server.xml,在HOST段中加入:
<Context path="" docBase="/var/wwwroot"
debug="0" reloadable="true" crossContext="true"/>
启动Apache和Tomcat
#cp apache-2.0/mod_jk.so /usr/local/apache/modules/
第二步:在/usr/local/apache/conf/下面建立两个配置文件mod_jk.conf和workers.properties。
vim mod_jk.conf
添加以下代码:
# 指出mod_jk模块工作所需要的工作文件workers.properties的位置
JkWorkersFile /usr/local/apache/conf/workers.properties
# Where to put jk logs
JkLogFile /usr/local/apache/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"
# 将所有servlet 和jsp请求通过ajp13的协议送给Tomcat,让Tomcat来处理
JkMount /servlet/* worker1
JkMount /*.jsp worker1
vim workers.properties
添加以下代码:
# Defining a worker named worker1 and of type ajp13
worker.list=worker1
# Set properties for worker1
worker.worker1.type=ajp13
worker.worker1.host=127.0.0.1
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
再配置httpd.conf,作以下修改:
将Listen 80 修改为 Listen 127.0.0.1:80
将ServerName 修改为 ServerName LocalHost:80
我的网页放在/var/wwwroot下,所以要修改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>
增加关于加载mod_jk的语句:
添加代码:
LoadModule jk_module modules/mod_jk.so
Include /usr/local/apache2/conf/mod_jk.conf
最后编辑Tomcat的配置文件server.xml,在HOST段中加入:
<Context path="" docBase="/var/wwwroot"
debug="0" reloadable="true" crossContext="true"/>
启动Apache和Tomcat
测试:
输入 http://127.0.0.1/index.jsp
输入 http://127.0.0.1/index.jsp
看到这个结果,不用说了,congratulations!!