2009-12-27 01:14五、生成mod_jk.so连接器
1. 拷贝源包到/usr/local并在目标目录中解压(当然在原来的目录中解压也是可以的,作者是为了规范所以安装的程序都放在/usr/local下)。
[root@localhost bin]# cd /usr/local
[root@localhost local]# tar -zxvf jakarta-tomcat-connectors- 1.2.15-src.tar.gz
2. 创建一个connector同步目录,目的是为了简化操作。
[root@localhost local]# ln -s tomcat-connectors-1.2.25-src connector
3. 进行编译配置。大家一定要注意这几个参数中前三个是很重要的,必要时可以去相应的目录看看相关的文件是否存在。
[root@localhost local]# cd connector/native
[root@localhost native]# ./buildconf.sh
[root@localhost native]#./configure --with-apxs=/usr/local/apache/bin/apxs --with-tomcat=/usr/local/tomcat --with-java-home=/usr/jdk --with-jni
4. 编译
[root@localhost apache]# make
5. 运行apache下的apxs,如果返回如下结果,证明正常。
[root@localhost native]# cd apache-2.0
[root@localhost apache-2.0]# /usr/local/apache/bin/apxs -n jk2 -i mod_jk.so
/usr/local/apache/build/instdso.sh SH_LIBTOOL='/usr/local/apache/build/libtool' mod_jk2.so /usr/local/apache/modules
/usr/local/apache/build/libtool --mode=install cp mod_jk.so /usr/local/apache/modules/
cp mod_jk.so /usr/local/apache/modules/mod_jk.so
Warning! dlname not found in /usr/local/apache/modules/mod_jk.so.
Assuming installing a .so rather than a libtool archive.
[root@localhost apache-2.0]# cp mod_jk.so /usr/local/apache/modules/
[root@localhost apache-2.0]#chmod 755 /usr/local/apache/modules/mod_jk.so
[root@localhost apache-2.0]# ll /usr/local/apache/modules/mod_jk.so
-rwxr-xr-x 1 root root 709215 08-14 10:22 /usr/local/apache/modules/mod_jk.so
mod_jk.so生成成功了。
六 配置解释jsp
1. 在Apache的conf目录中创建文件vim mod_jk.conf 和workers.properties
[root@localhost conf]# cd /usr/local/apache/conf
配置mod_jk.conf
[root@localhost conf]# vi mod_jk.conf
加入如下配置:
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"
# 将所有jsp、htm、action等请求通过ajp13的协议送给Tomcat,让Tomcat来处理
JkMount /*.jsp worker1
JkMount /*.htm worker1
JkMount /*.action worker1
JkMount /*.do worker1
JKUnmount /*.html worker1
保存退出
配置workers.properties
[root@localhost conf]# vi workers.properties
加入如下配置:
#------start ---------
# 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
# --------end ------------
保存退出
2. 配置Apache的/usr/local/apache/conf/httpd.conf,使apache启动时加载mod_jk.so
[root@localhost conf]# cd /usr/local/apache/conf
[root@localhost conf]# vi httpd.conf
在LoadModule后加入下面三行
LoadModule jk_module modules/mod_jk.so
JkShmFile /usr/local/apache/logs/k2.shm
Include /usr/local/apache/conf/mod_jk.conf
3.配置虚拟主机
去掉httpd.conf文件中Include conf/extra/httpd-vhosts.conf语句前的注释“#”并保存退出
编辑httpd-vhosts.conf
[root@localhost conf]# cd ./extra/httpd-vhosts.conf
配置如下:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin
[email protected]
DocumentRoot "/var/www/"
ServerName www.test.com #域名由自己定
CustomLog logs/www.test.com-access_log common
</VirtualHost>
到此配置完毕!!
七、测试
1. 找一个jsp工程复制到/var/www目录下,如Test,没有的话就用tomcat容器webapps目录下的example
1. 在tomcat的webapps目录下建立以个链接
[root@localhost local]# cd /usr/local/apache-tomcat-6.0.14-src/webapps
[root@localhost webapps]# ln –s /var/www/Test Test
(这一步也可不做,但要修改server.xml中的工程默认路径为”/var/www/”---不建议这么做)
2. 启动Tomcat、apache
[root@localhost conf]# cd /usr/local/tomcat/bin
[root@localhost bin]# ./shutdown.sh
[root@localhost bin]# ./startup.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JAVA_HOME: /usr/local/jdk
[root@localhost bin]# cd /usr/local/apache/bin
[root@localhost bin]# ./apachectl restart
打开浏览器,输入http://主机地址/ examples
如http://192.168.1.254/Test/index.jsp
测试jsp文件是否可以正常打开,如果都可以,恭喜你整合成功!