此玩意儿与lucene配合用.备忘之..
OS Centos5.2
需要的包:
httpd-2.2.3-11.el5_1.centos.3.i386.rpm
httpd-devel-2.2.3-11.el5_1.centos.3.i386.rpm
apache-tomcat-6.0.20.tar.gz
jdk-6u14-linux-i586-rpm.bin
tomcat-connectors-1.2.28-src.tar.gz
安装apache和jdk:
rpm -ivh httpd* (httpd-devel依赖apr的包)
./jdk-6u14-linux-i586-rpm.bin
加入环境变量:
vim /etc/profile
JAVA_HOME=/usr/java/jdk1.6.0_14
export JAVA_HOME
PATH=$PATH:/usr/java/jdk1.6.0_14/bin
export PATH
export CATALINA_HOME=/usr/local/tomcat
export TOMCAT_HOME=/usr/local/tomcat
source /etc/profile
安装配置tomcat:
tar xf apache-tomcat-6.0.20.tar.gz
mv apache-tomcat-6.0.20 /usr/local/tomcat
cp /usr/local/tomcat /usr/local/tomcat2
修改2个tomcat的配置文件。确保端口都不相同否则会冲突。否则只能起来一个。
vim /usr/local/tomcat/conf/server.xml
<Connector port="8080" protocol="HTTP/1.1"
maxThreads="200"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8109" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="worker1">
vim /usr/local/tomcat2/conf/server.xml
<Server port="8106" shutdown="SHUTDOWN">
<Connector port="8088" protocol="HTTP/1.1"
maxThreads="200"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8209" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="worker2">
定制tomcat启动脚本:
tomcat1的脚本:
cat /usr/local/tomcat/bin/start.sh
#!/bin/bash
export CATALINA_HOME=/usr/local/tomcat
export TOMCAT_HOME=/usr/local/tomcat
./startup.sh
export CATALINA_HOME=/usr/local/tomcat2
export TOMCAT_HOME=/usr/local/tomcat2
cat /usr/local/tomcat/bin/stop.sh
#!/bin/bash
export CATALINA_HOME=/usr/local/tomcat
export TOMCAT_HOME=/usr/local/tomcat
./shutdown.sh
export CATALINA_HOME=/usr/local/tomcat2
export TOMCAT_HOME=/usr/local/tomcat2
tomcat2的脚本:
cat /usr/local/tomcat2/bin/start.sh
#!/bin/bash
export CATALINA_HOME=/usr/local/tomcat2
export TOMCAT_HOME=/usr/local/tomcat2
./startup.sh
export CATALINA_HOME=/usr/local/tomcat
export TOMCAT_HOME=/usr/local/tomcat
cat /usr/local/tomcat2/bin/stop.sh
#!/bin/bash
export CATALINA_HOME=/usr/local/tomcat2
export TOMCAT_HOME=/usr/local/tomcat2
./shutdown.sh
export CATALINA_HOME=/usr/local/tomcat
export TOMCAT_HOME=/usr/local/tomcat
安装mod_jk模块:(要装apr的包,也就是的httpd-xxx-devel所依赖的包)
tar xf tomcat-connectors-1.2.28-src.tar.gz
cd tomcat-connectors-1.2.28-src/native
./configure --with-apxs=/usr/sbin/apxs --with-jni --with-apr-lib=/usr/lib
make&&make install
确保" /usr/lib/httpd/modules/mod_jk.so"存在且为755权限
在apache配置文件中加入模块的配置参数:
LoadModule jk_module modules/mod_jk.so
<IfModule mod_jk.c>
jkWorkersFile /etc/worker.properties
jkMountFile /etc/uriworkermap.properties
jkLogFile /var/log/mod_jk.log
jkLogLevel warn
jkShmFile /tmp/jk.shm
</IfModule>
在/etc下创建apache中模块参数中的配置文件于日志文件:
vim /etc/worker.properties (定义2个成员,注意:端口一定要和server.xml里相对应)
worker.list=worker1,worker2
worker.worker1.port=8109
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.worker2.type=ajp13
worker.worker2.port=8209
worker.worker2.host=localhost
vim /etc/uriworkermap.properties (定义uri请求的转发规则.)
/.*jsp=worker2
/hse/search=worker2
/hse/engine=worker1
/*.*=worker2
touch /var/log/mod_jk.log (不创建这个日志文件会导致apache起不来)
测试:
启动apache和tomcat.(确保2个tomcat能起来后再测试)
http://127.0.0.1:8080
http://127.0.0.1:8088
http://127.0.0.1 (apache的网站根目录与tomcat的目录指到一个,并注意权限)