软件下载:tomcat 5.5.9
http://mirror.vmmatrix.net/apache/dist/jakarta/tomcat-5/v5.5.9/bin/jakarta-tomcat-5.5.9.tar.gz
jk 1.2.14
http://www.apache.org/dist/jakarta/tomcat-connectors/jk/source/jk-1.2.14/jakarta-tomcat-connectors-1.2.14-src.tar.gz
安装tomcat
将下载的tomcat放到/usr/local目录下解压缩
tar zxvf jakarta-tomcat-5.*.tar.gz
将解压缩后目录改为tomcat
mv jakarta-tomcat-5.5.9 tomcat
启动tomcat
cd /usr/local/tomcat/bin
./startup.sh
输出如下代表启动成功
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/lib/java
这个时候应该可以通过访问服务器的8080端口出现tomcat服务器的默认界面了。
如下
安装jk 1.2.14
将文件jakarta-tomcat-connectors-1.2.14-src.tar.gz在/usr/local目录解压缩
cd /usr/local/
tar zxvf jakarta-tomcat-connectors*.tar.gz
编译安装
cd /usr/local/jakarta-tomcat-connectors-1.2.14-src/jk/native
./buildconfig.sh
./configure ?with-apxs="/usr/sbin/apxs” ?with-java-home="/usr/lib/java
make
make install
到这里jk 1.2.14已经安装好了。
配置apache可以解释jsp文件
拷贝mod_jk.so文件到/usr/libexec/apache目录下
cp /usr/local/jakarta-tomcat-connectors-1.2.14-src/jk/native/apache-1.3/mod_jk.so /usr/libexec/apache/
拷贝/usr/local/tomcat/conf/workers.properties.minimal文件到/etc/apache/workers.properties文件
cp /usr/local/tomcat/conf/workers.properties.minimal /etc/apache/workers.properties
写入/etc/apache/mod_jk.conf文件,内容如下
<IfModule mod_jk.c>
JkWorkersFile /etc/apache/workers.properties
JkLogFile /var/log/mod_jk.log
JkLogLevel warn
# Sample JkMounts. Replace these with the paths you would
# like to mount from your JSP server.
JkMount /*.jsp ajp13w
JkMount /servlet/* ajp13w
JkMount /examples/* ajp13w
</IfModule>
编辑/etc/apache/httpd.conf文件,加入如下内容
LoadModule jk_module libexec/apache/mod_jk.so
AddModule mod_jk.c
Include /etc/apache/mod_jk.conf
将/var/www/htdocs目录链接到/usr/local/tomcat/webapps/ROOT目录
注意:要先将原ROOT目录改名
cd/usr/local/tomcat/webapps/
mv ROOT ROOTBAK
ln -s /var/www/htdocs /usr/local/tomcat/webapps/ROOT
cp -r /usr/local/tomcat/webapps/ROOTBAK/* /usr/local/tomcat/webapps/ROOT/
重新启动tomcat和apache
cd /usr/local/tomcat/bin
./shutdown.sh
./startup.sh
/etc/rc.d/rc.httpd restart
现在直接访问服务器/index.jsp就可以显示tomcat界面了。例如我的服务器是192.168.0.254
我在/var/www/htdocs/目录下有index.html index.php index.jsp三个文件
下面是分别访问的截图
index.html
index.php
index.jsp
祝好运!