Linux中安装tomcat

官网:http://tomcat.apache.org/
1.下载TOMCAT
    wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-8/v8.5.30/bin/apache-tomcat-8.5.30.tar.gz
2.解压到指定目录
    tar -zxvf apache-tomcat-8.5.30.tar.gz -C /usr/local/
3.配置开机自启 service启动
-3.0编辑文件
    vi /etc/init.d/tomcat
-3.1复制一下脚本内容(修改JDK、TOMCAT路径)
#!/bin/bash  
# description: Tomcat7 Start Stop Restart  
# processname: tomcat7  
# chkconfig: 234 20 80  
JAVA_HOME=/usr/local/jdk1.8.0_161
export JAVA_HOME  
PATH=$JAVA_HOME/bin:$PATH  
export PATH  
CATALINA_HOME=/usr/local/apache-tomcat-8.5.30
case $1 in  
start)  
sh $CATALINA_HOME/bin/startup.sh  
;;   
stop)     
sh $CATALINA_HOME/bin/shutdown.sh  
;;   
restart)  
sh $CATALINA_HOME/bin/shutdown.sh  
sh $CATALINA_HOME/bin/startup.sh  
;;
log)  
tail -f $CATALINA_HOME/logs/catalina.out
;;  
esac      
exit 0
4.设置服务权限、运行级别、开机自启
    chmod a+x /etc/init.d/tomcat
    chkconfig tomcat on
    chkconfig --add tomcat
5.查看服务列表
    chkconfig --list
6.TOMCAT服务命令
    service tomcat start
    service tomcat stop
    service tomcat restart
    service tomcat status
Logo

更多推荐