日期:2014-05-16 浏览次数:20833 次
1. 准备
RedHat 9.0(原则上 RH7,8,9,ES/AS2.1,3都适用,其他 Linux 或者 FreeBsd 未试过);
j2sdk-1_4_2_05-linux-i586.bin(JAVA_HOME=/usr/local/java,如果不同下面相应地方也要修改)
jakarta-tomcat-5.0.28.tar.gz(CATALINA_HOME=/usr/local/tomcat,如果不同下面相应地方也要修改)
安装过程不再赘述。
2. 配置Tomcat
按照通常在 Linux 下配置 Tomcat 的步骤作就可以了。:) 注意不要与其他已用的端口冲突。然后根据[1]中的内容运行如下命令:
? $ cd $CATALINA_HOME/bin
??$ tar xvfz jsvc.tar.gz
??$ cd jsvc-src
??$ ./configure --with-java=/usr/local/java?
??$ make
??$ cp jsvc ..
??$ cd ..
运行如下命令启动Tomcat:
? $ cd $CATALINA_HOME
??$ ./bin/jsvc -Djava.endorsed.dirs=./common/endorsed -cp ./bin/bootstrap.jar \
????-outfile ./logs/catalina.out -errfile ./logs/catalina.err \
????org.apache.catalina.startup.Bootstrap
使用浏览器访问一下 http://<host>:<port
>,确认一下是否已经启动 Tomcat。
3. 编写service脚本
服务脚本名定为 tomcat5(参见5.),当然可以自行修改,只要不与已有服务重名。然后将 tomcat5 复制到 /etc/init.d 目录下。
# cd /etc/init.d
# chkconfig --add tomcat5
# chkconfig tomcat5 on
# /etc/init.d/tomcat5 stop
# /etc/init.d/tomcat5 start
使用浏览器访问 http://<host>:<port
>,确认一下是否已经启动 Tomcat。
# reboot
OK!
4. 参考
[1]. Tomcat 5.0 Setup. (http://jakarta.apache.org/tomcat/tomcat-5.0-doc/setup.html
)
5. 附:tomcat5脚本内容
注意,其中部分内容要根据实际的目录进行修改。
#!/bin/sh
##############################################################################
#
#?? Copyright 2004 The Apache Software Foundation.
#
#?? Licensed under the Apache License, Version 2.0 (the "License");
#?? you may not use this file except in compliance with the License.
#?? You may obtain a copy of the License at
#
#??????
http://www.apache.org/licenses/LICENSE-2.0
#
#?? Unless required by applicable law or agreed to in writing, software
#?? distributed under the License is distributed on an "AS IS" BASIS,
#?? WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#?? See the License for the specific language governing permissions and
#?? limitations under the License.
##############################################################################
#
# Small shell script to show how to start/stop Tomcat using jsvc
# If you want to have Tomcat running on port 80 please modify the server.xml
# file:
#
#??? <!-- Define a non-SSL HTTP/1.1 Connector on port 80 -->
#??? <Connector className="org.apache.catalina.connector.http.HttpConnector"
#?????????????? port="80" minProcessors="5" maxProcessors="75"
#?????????????? enableLookups="true" redirectPort="8443"
#?????????????? acceptCount="10" debug="0" connectionTimeout="60000"/>
#
# That is for Tomcat-5.0.x (Apache Tomcat/5.0)
#
# tomcat5???? This shell script takes care of starting and stopping
#???????????? standalone Tomcat-5.0.x
#
# chkconfig: - 60 50
# description: Tomcat is a JSP server daemon.
# processname: tomcat5
# Source function library.
. /etc/rc.d/init.d/functions
# Adapt the following lines to your configuration
JAVA_HOME=/usr/local/java
CATALINA_HOME=/usr/local/tomcat
DAEMON_HOME=$CATALINA_HOME/common/daemon
TOMCAT_USER=root
TMP_DIR=/var/tmp
CATALINA_OPTS=
CLASSPATH=\
$JAVA_HOME/lib/tools.jar:\
$CATALINA_HOME/bin/commons-daemon.jar:\
$CATALINA_HOME/bin/bootstrap.jar
RETVAL=0
prog="tomcat5"