1、准备所需的软件包
httpd-2.2.21.tar.gz Apache
jdk-6u29-linux-x64.bin JDK
jakarta-tomcat-connectors-jk-1.2.6-src.tar.gz JK模块
apache-tomcat-7.0.22.tar.gz Tomcat
2、安装Apache
[root@localhost local]#tar zxvf httpd-2.2.21.tar.gz
[root@localhost local]#mkdir apache2
[root@localhost local]#cd httpd-2.2.21
[root@localhost httpd-2.2.21]#./configure –prefix=/usr/local/apache2 \
–enable-modules=most –enable-mods-shared=all –enable-so
[root@localhost httpd-2.2.21]#make
[root@localhost httpd-2.2.21]#make install
3、安装Tomcat
[root@localhost local]#tar zxvf apache-tomcat-7.0.22.tar.gz
[root@localhost local]#mv apache-tomcat-7.0.22.tar.gz tomcat7.0.22
4、安装JDK
[root@localhost local]#chmod 775 jdk-6u29-linux-x64.bin
[root@localhost local]#./jdk-6u29-linux-x64.bin
5、安装JK模块
[root@localhost local]#tar zxvf jakarta-tomcat-connectors-jk-1.2.6-src.tar.gz
[root@localhost local]#cd jakarta-tomcat-connectors-jk-1.2.6-src/jk/native
[root@localhost native]#chmod 755 buildconf.sh
[root@localhost native]#./configure –with-apxs=/usr/local/apache2/bin/apxs
[root@localhost native]#make
[root@localhost native]#make install
完成之后我们可以看到在apache的modules目录下会生成一个名为mod_jk.so的文件。
6、Apche与Tomcat整合
(1)在/usr/local/apache2/conf/下面建立两个配置文件mod_jk.conf和workers.properties。
内容如下:
[root@localhost conf]# cat mod_jk.conf
JkWorkersFile /usr/local/apache2/conf/workers.properties
JkLogFile /usr/local/apache2/logs/mod_jk.log
JkLogLevel info
JkLogStampFormat “[%a %b %d %H:%M:%S %Y]“
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat “%w %V %T”
JkMount /servlet/* worker1
JkMount /*.jsp worker1
[root@localhost conf]# cat 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=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
(2)配置Apache配置文件httpd.conf
修改ServerName为ServerName 192.168.150.151:80
在DirectoryIndex中添加 index.jsp
增加关于加载mod_jk的语句:
LoadModule jk_module modules/mod_jk.so
Include conf/mod_jk.conf
修改网页站点主目录:DocumentRoot “/webdata/www”
更改目录权限:
<Directory “/webdata/www”>
Options Includes FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
XBitHack on
</Directory>
<Directory “/webdata/www/WEB-INF”>
Order deny,allow
Deny from all
</Directory>
(3)配置Tomcat配置文件server.xml,在Host段加入:
<Context path=”" docBase=”/webdata/www” debug=”0″ reloadable=”true”
crossContext=”true”/>
(4)在catalina.sh中指定Java环境变量,编辑Tomacat下catalina.sh文件。指定Java环境变量。
在catalina.sh中加入如下内容:
# OS specific support. $var _must_be set to either true or flase.
JAVA_HOME=/usr/local/jdk1.6.0_29
export JAVA_HOME
cygwin=false
os400=false
(5)新建站点目录,将测试页面复制到站点目录下。
[root@localhost /]#mkdir /webdata/www
[root@localhost /]#cp -r /usr/local/tomcat1.2.15/webapps/ROOT/* /webdata/www
7、测试Apache与Tomcat整合
启动Apache和Tomcat服务。
在浏览器中输入出现Tomcat默认的Jsp页面。