服务器环境:Apache/2.2.15 tomcat/6.0.35
当apache和tomcat装好以后,apache和tomcat还没有结合,我要实现的目标是所有静态内容,图片,JS,CSS,HTML通过前端APACHE
解析,而JSP的内容通过后端的TOMCAT解析
软件下载:http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/ 官方网站,找到对应版本的tomcat-connectors下载
安装:我下载的是mod_jk-1.2.30-httpd-2.2.X.so,把这个文件改名成mod_jk.so放入/etc/httpd/modules目录下
修改配置文件:
修改/etc/httpd/conf目录下httpd.conf,在文件末尾加入
#for tomcat
include "/etc/httpd/conf/mod_jk.conf"
新建/etc/httpd/conf/mod_jk.conf,内容为
#Load mod_jk module
LoadModule jk_module modules/mod_jk.so
#Where to find workers.properties
JkWorkersFile conf/workers.properties
#Where to put jk logs
JklogFile 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"
#Send servlet for context /examples to worker named ajp13
#JkMount /servlet/* ajp13
#Send JSPs for context /examples to worker named ajp13
JkMount /*.jsp ajp13
配置worker,在/etc/httpd/conf/下新建workers.properties文件,其内容为
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
worker.ajp13.lbfactor=1
重启APACHE即可
开始运行JSP的没有问题,能正常访问,但我的网站又用到了.do和.action后缀名的文件。
解决如上问题,只需要在/etc/httpd/conf/mod_jk.conf文件最后面加上
JkMount /*.do ajp13
JkMount /*.action ajp13
保存,重启apache,一切都正常了
OK,完成
转载请注明:IT运维空间 » linux » apache tomcat整合
发表评论