centos7 tomcat_Centos7配置tomcat

89cbb441093312f97d2308b38fb046ee.png

一、创建/opt/service目录,用于安装nginx的位置

管理员(root):
mkdir /opt/service
非管理员(not root):
sudo mkdir /opt/service

二、上传/解压

将apache-tomcat-8.5.23.tar.gz上传到服务器的/opt/service。

可以使用FileZilla将文件上传到服务器

cd /opt/service        #切换到/opt/service目录下
tar -zxvf apache-tomcat-8.5.23.tar.gz   #解压到当前目录
rm -f apache-tomcat-8.5.23.tar.gz        #删除apache-tomcat-8.5.23.tar.gz

三、配置开机自动启动

1.在vi /etc/systemd/system/tomcat.service配置(如果没有该文件,就新建一个)

tomcat.service文件配置如下

[Unit]
Description=tomcat
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=oneshot
Environment='JAVA_HOME=/usr/java/jdk1.8.0_131'  # jdk
Environment='JRE_HOME=/usr/java/jdk1.8.0_131/jre' #jre
ExecStart=/opt/service/apache-tomcat-8.5.23/bin/startup.sh # tomcat start
ExecStop=/opt/service/apache-tomcat-8.5.23/bin/shutdown.sh # tomcat stop
ExecReload=/bin/kill -s HUP $MAINPID
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

2.启动服务

[root@localhost system]# systemctl start tomcat.service
...
stop n Stop Catalina, waiting up to n seconds for the process to end
stop -force Stop Catalina, wait up to 5 seconds and then use kill -KILL if still running
stop n -force Stop Catalina, wait up to n seconds and then use kill -KILL if still running
configtest Run a basic syntax check on server.xml - check exit code for result
version What version of tomcat are you running?
Note: Waiting for the process to end and use of the -force option require that $CATALINA_PID is defined

提示$CATALINA_PID异常提示则需要在setclasspath.sh配置jdk信息

[root@localhost bin]# vim setclasspath.sh
export JAVA_HOME=/usr/local/java/jdk1.8.0_144
export JRE_HOME=/usr/local/java/jdk1.8.0_144/jre
# 保存即可。

3. 设置服务启动

设置开机启动
# systemctl enable tomcat.service

查询当前tomcat的状态:
# systemctl status tomcat.service

关闭tomcat:
# systemctl stop tomcat.service

关闭开机自启:
# systemctl disable tomcat.service

# 开启服务
systemctl start tomcat.service
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值