先从tomcat网站上下载最新的gz安装包
文件名:apache-tomcat-8.0.8.tar.gz
将文件上传到/usr/local目录中
执行解压缩
tar zxvf apache-tomcat-8.0.8.tar.gz
将目录apache-tomcat-8.0.8命名为tomcat
mv apache-tomcat-8.0.8 tomcat
运行/usr/local/tomcat/bin/startup.sh就会启动tomcat
配置自动启动脚本:
#!/bin/bash # chkconfig: - 85 15 # description: Tomcat Server basic start/shutdown script # processname: tomcat JAVA_HOME=/usr/java/jdk1.8.0_05 export JAVA_HOME TOMCAT_HOME=/usr/local/tomcat/bin START_TOMCAT=/usr/local/tomcat/bin/startup.sh STOP_TOMCAT=/usr/local/tomcat/bin/shutdown.sh start() { echo -n "Starting tomcat: " cd $TOMCAT_HOME ${START_TOMCAT} echo "done." } stop() { echo -n "Shutting down tomcat: " cd $TOMCAT_HOME ${STOP_TOMCAT} echo "done." } case "$1" in start) start ;; stop) stop ;; restart) stop sleep 10 start ;; *) echo "Usage: $0 {start|stop|restart}" esac exit 0
将文件命名为tomcat放到/etc/init.d/目录下
修改权限,可以运行
chmod +x /etc/init.d/tomcat
设置开机自动启动服务
sudo chkconfig tomcat on
启动服务:
service tomcat start
停止服务:
service tomcat stop
配置防火墙打开对应的端口:
vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
重启防火墙
service iptables restart
在CentOS上安装tomcat,布布扣,bubuko.com
原文:http://www.cnblogs.com/xsi640/p/3757015.html