原文链接:http://www.cnblogs.com/xsi640/p/3757015.html
另外一个比较详细的博文:http://blog.csdn.net/zhngjan/article/details/25223423
先从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 # # tomcat startup script for the Tomcat server # # chkconfig: 345 80 20 # description: start the tomcat deamon # # Source function library . /etc/rc.d/init.d/functions prog=tomcat JAVA_HOME=/usr/java/jdk1.6.0_27 export JAVA_HOME CATALANA_HOME=/usr/local/tomcat export CATALINA_HOME case "$1" in start) echo "Starting Tomcat..." $CATALANA_HOME/bin/startup.sh ;; stop) echo "Stopping Tomcat..." $CATALANA_HOME/bin/shutdown.sh ;; restart) echo "Stopping Tomcat..." $CATALANA_HOME/bin/shutdown.sh sleep 2 echo echo "Starting Tomcat..." $CATALANA_HOME/bin/startup.sh ;; *) echo "Usage: $prog {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
时间: 2024-10-10 18:13:49