linux安装tomcat
一:下载tomcat
地址:点击打开链接
二:上传、解压
- [root@localhost java]# cd /usr/local
将下载好的apache-tomcat-8.5.28.tar.gz上传到usr/local目录
- [root@localhost tomcat]# tar -zxvf apache-tomcat-8.5.28.tar.gz #解压
- [root@localhost tomcat]# mv apache-tomcat-8.5.28 tomcat #重命名
三:配置tomcat作为服务开机启动
1.将下面一段代码保存为tomcat文件
- #!/bin/bash
- #
- # kenny kenny.zhou@tom.com
- # /etc/rc.d/init.d/tomcat
- # init script for tomcat precesses
- #
- # processname: tomcat
- # description: tomcat is a j2se server
- # chkconfig: 2345 86 16
- # description: Start up the Tomcat servlet engine.
- if [ -f /etc/init.d/functions ]; then
- . /etc/init.d/functions
- elif [ -f /etc/rc.d/init.d/functions ]; then
- . /etc/rc.d/init.d/functions
- else
- echo -e "/atomcat: unable to locate functions lib. Cannot continue."
- exit -1
- fi
- RETVAL=$?
- CATALINA_HOME="/usr/local/tomcat" #tomcat安装目录
- case "$1" in
- start)
- if [ -f $CATALINA_HOME/bin/startup.sh ];
- then
- echo $"Starting Tomcat"
- $CATALINA_HOME/bin/startup.sh
- fi
- ;;
- stop)
- if [ -f $CATALINA_HOME/bin/shutdown.sh ];
- then
- echo $"Stopping Tomcat"
- $CATALINA_HOME/bin/shutdown.sh
- fi
- ;;
- *)
- echo $"Usage: $0 {start|stop}"
- exit 1
- ;;
- esac
- exit $RETVAL
- [root@localhost tomcat]# mv tomcat /etc/init.d/
- [root@localhost tomcat]# chmod 777 /etc/init.d/tomcat
- [root@localhost tomcat]# chkconfig --add tomcat
- [root@localhost tomcat]# chkconfig --list
- #显示内容中如果包括tomcat则配置成功
- tomcat 0:off 1:off 2:on 3:on 4:on 5:on 6:off
- export JAVA_HOME=/usr/local/java/jdk
- export CATALINA_HOME=/usr/local/tomcat
- export CATALINA_BASE=/usr/local/tomcat
- export CATALINA_TMPDIR=/usr/local/tomcat/temp
五:关闭防火墙,进行测试
- [root@localhost bin]# service iptables stop
启动tomcat:service tomcat start
关闭tomcat:service tomcat stop
测试访问:
原文链接:http://blog.csdn.net/qq_37936542/article/details/79497510
文末福利:
福利一:前端,Java,产品经理,微信小程序,Python等资源合集大放送:https://www.jianshu.com/p/e8197d4d9880
福利二:微信小程序入门与实战全套详细视频教程:https://www.jianshu.com/p/e8197d4d9880
领取方式:
如果需要学习视频,欢迎关注 【编程微刊】微信公众号,回复【领取资源】一键领取以下所有干货资源,获取更多有用技术干货、文档资料。所有文档会持续更新,欢迎关注一起成长!