#添加tomcat用户
useradd tomcat -M -d / -s /sbin/nologin
#设置JAVA_HOME环境变量(如果已设置可忽略)
export JAVA_HOME=/data/java/jdk1.6
#编译jsvc
cd /data/tomcats/tomcat7/bin
tar zxvf commons-daemon-native.tar.gz
cd commons-daemon-1.0.10-native-src/unix
./configure
make
cp jsvc ../..
cd ../..
#复制init启动脚本
cp /data/tomcats/tomcat7/bin/daemon.sh /etc/init.d/tomcat7
#修改init启动脚本(否则不支持chkconfig),在前面加入以下代码
### BEGIN INIT INFO
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start tomcat at boot time
# Description: Enable service provided by tomcat.
### END INIT INFO
CATALINA_HOME=/data/tomcats/tomcat7
JAVA_HOME=/data/java/jdk1.6
export CATALINA_HOME
export JAVA_HOME
#添加到启动项
chkconfig --add tomcat7
#tomcat默认HTTP端口改为80
#修改conf/server.xml把8080替换为80
#测试
/etc/init.d/tomcat7 start
#这时可看到tomcat的logs目录已生成了日志文件
参考:
http://tomcat.apache.org/tomcat-7.0-doc/setup.html
转载于:https://my.oschina.net/scriptboy/blog/95814