Ubuntu 下 Apache2 与Tomcat5 的交配指南 1)下载apache与tomcat的连接器mod_jk2: http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/linux/jk-1.2.25/i386/mod_jk-1.2.25-httpd-2.2.4.so 重命名为mod_jk.so.一会有用的。安装成功jdk和tomcat后再安装apache2(建议不要用apt-get install安装jdk和tomcat,先下载jdk的.bin文件和tomcat的tar.gz文件,然后安装并配制)
jdk1.6下载:http://192.18.108.239/ECom/EComTicketServlet/BEGINC05AB4EFEFC50B11B97E9F345964E661/-2147483648/2432646435/1/852698/852662/2432646435/2ts+/westCoastFSEND/jdk-6u3-nb-5.5.1-oth-JPR/jdk-6u3-nb-5.5.1-oth-JPR:2/jdk-6u3-nb-5_5_1-linux-ml.bin tomcat下载: http://apache.mirror.phpchina.com/tomcat/tomcat-5/v5.5.25/bin/apache-tomcat-5.5.25.tar.gz
安装jdk和tomcat: ./jdk-6u3-nb-5_5_1-linux-ml.bin即可安装jdk选择路径为/opt/jdk
将tomcat包考到opt解压之后:/opt/tomcat
配制:(在/root/.bashrc中添加以下) export JAVA_HOME=/opt/jdk export TOMCAT_HOME=/opt/tomcat export JRE_HOME=$JAVA_HOME/jre export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/bin:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar export CATALINA_HOME=$TOMCAT_HOME export CATALINA_BASE=$TOMCAT_HOME 然后在终端输入以下命令检查环境变量是否成功: root#echo $JAVA_HOME
root#echo $CLASSPATH
root#echo $PATH root#java -version
在jdk和tomcat安装配制成功后装apache2. apt-get install apache2安装apache,主要安装目录为: /usr/lib/apache2 /usr/share/apache2 /etc/apache2
2)将mod_jk.so放到/usr/lib/apache2/modules目录中。或者用apt-get install libapache2-mod-jk则下载mod_jk.so到modules中,而且在/etc/apache2/mods-available中加了 jk.load文件。
3)在/etc/apache2/httpd.conf中添加:
JkWorkersFile "/etc/apache2/workers.properties"
JkLogFile "/var/log/apache2/mod_jk.log"
JkLogLevel severe
JkMount /WEB/* ajp13
JkMount /*.jsp ajp13
JkMount /WEB-INF/* ajp13 或者新建/etc/apache2/mods-available/jk.conf文件,内容同httpd.conf。(这种方法好像不行)
4)新建/etc/apache2/workers.properties,内容为:
workers.tomcat_home=/opt/tomcat5.5 #让mod_jk模块知道Tomcat
workers.Java_home=/opt/jdk1.5 #让mod_jk模块知道j2sdk
ps=\
worker.list=ajp13 #模块版本,现有ajp14了,不要修改
worker.ajp13.port=8009 #工作端口,若没占用则不用修改
worker.ajp13.host=localhost #本机,若上面的Apache主机不为localhost,作相应修改
worker.ajp13.type=ajp13 #类型
worker.ajp13.lbfactor=1 #代理数,不用修改
5)到/opt/tomcat/bin目录下执行:. /startup.sh启动tomcat 再启动apache2 : /etc/init.d/apache2 start 测试:在firefox的地址栏中输入:http://localhost:8080/index.jsp 与http://localhost/index.jsp 看效果是否一样。如果一样,祝贺你!!