为什么要把apache+tomcat整合呢?因为tomcat负载不怎么样
,所以想让apache帮忙处理静态页面
,图片等,它自己处理逻辑
。第一步安装
1. 安装tomcat 、httpd、My
SQL 这些就不说了
2. apache要安装的组建
# rpm -ivh apr-devel-0.9.4-24.9.i386.rpm
# rpm -ivh apr-util-devel-0.9.4-21.i386.rpm
# rpm -ivh pcre-devel-4.5-4.el4_5.1.i386.rpm
# rpm -ivh httpd-devel-2.0.52-38.ent.centos4.i386.rpm
重点是 httpd-devel 装了它,才会有 /usr/sbin/apxs
3. 去官方下载 Tomcat Connectors 并安装
[root@c1 ~]# wget http://mirror.bjtu.edu.cn/apache//tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.32-src.tar.gz
[root@c1 ~]# cd tomcat-connectors-1.2.32-src/native/
[root@c1 native]# ./configure –with-apxs=/usr/sbin/apxs
[root@c1 native]# make && make install
查看apache的modules目录下有没有 mod_jk.so
[root@c1 native]# cd /usr/lib/httpd/modules/
4. 配置apache
让apache支持jk模块
[root@c1 ~]# vi /etc/httpd/conf/httpd.conf
DirectoryIndex index.
jsp index.html index.html.var
LoadModule jk_module modules/mod_jk.so
include conf/extra/mod_jk.conf
[root@c1 ~]# vi /etc/httpd/conf/extra/mod_jk.conf
JkWorkersFile conf/extra/workers.properties
JkLogFile logs/mod_jk.log
JkShmFile logs/jk-runtime-status
JkLogLevel info
JkLogStampFormat “[%a %b %d %H:%M:%S %Y] “
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat “%w %V %T”
#Sample JkMounts. Replace these with the paths you would
#like to mount from your JSP server.
#syntax: JkMount ${URL_DIR}/*.
jsp worker_name
JkMount /images/avatar/* worker1
JkMount /*.jsp worker1
JkMount /*.page worker1
JkMount /*.cic worker1
JkMount /func/* worker1
JkMount /assets/* worker1
JkMount /remote/* worker1
JkMount /services/* worker1
JkMount /homebase/* worker1
JkMount /skin/* worker1
JkMount /error/* worker1
JkMount /lib/* worker1
JkMount /protected/* worker1
JkMount /rounded/* worker1
JkMount /FormOverLogin* worker1
JkMount /fckeditor/editor/filemanager/connectors/* worker1
JkMount /upload/image/* worker1
[root@c1 ~]# vi /etc/httpd/conf/extra/workers.properties
worker.list=worker1
worker.worker1.port=8009 #注意这里是tomcat对应的Connector 端口
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.woker1.lbfactor=1
最后修改 tomcat 和 apache 指向同一个目录
<Host name=www.e2fsck.org appBase=”webapps”
unpackWARs=”true” autoDeploy=”true”
xmlValidation=”false” xmlNamespaceAware=”false”>
<Context path=”" docBase=”/var/www/html” debug=”0″/>
第二步 测试
jsp测试页面,写如下代码到 /var/www/html/index.jsp
<html>
<body>
<h1>JSP Test Page</h1>
<%=new java.util.Date()%>
</body>
</html>
重启tomcat测试!