linux 设置tomcat开机启动

1、设置Tomcat开机自启

在/etc/systemd/system路径下创建tomcat.service文件

命令:vim /etc/systemd/system/tomcat.service

将以下内容添加到omcat.service中:

bash 复制代码
[Unit]
Description=tomcat-server
After=network.target

[Service]
Type=forking

Environment="JAVA_HOME=/opt/jdk1.6.0_45"   #jdk安装目录

ExecStart=/home/apache-tomcat-7.0.100/bin/startup.sh  #tomcat安装目录
ExecStop=/home/apache-tomcat-7.0.100/bin/shutdown.sh  #tomcat安装目录
ExecReload=/bin/kill -s HUP $MAINPID

User=root
Group=root

[Install]
WantedBy=multi-user.target

2、重新加载 systemd 的配置

bash 复制代码
systemctl daemon-reload

3、启用Tomcat服务

bash 复制代码
systemctl enable tomcat.service

4、使用以下命令启动 Tomcat 服务,测试之前记得停止运行的tomcat

bash 复制代码
systemctl start tomcat.service

5、查看启动状态,如下图:

bash 复制代码
 systemctl status tomcat.service
相关推荐
Avan_菜菜10 小时前
FRP 内网穿透完整实战:从 HTTP 映射到 HTTPS 自签代理
运维·nginx·https
Sokach101519 小时前
Linux Shell 脚本从零到能用:一个新手的一天学习总结
linux
SelectDB1 天前
Litefuse 开源并推出单进程轻量模式,25 秒就能跑起来的 Agent 可观测与评估平台
运维·后端·自动化运维
AlfredZhao1 天前
Docker 容器时区不对,`timedatectl` 不存在怎么办?
linux·timezone
zzzzzz3103 天前
9K Star 炸裂开源!这个 C 语言写的代码知识图谱,把 Linux 内核索引压缩到了 3 分钟
linux·服务器·sql
XIAOHEZIcode3 天前
Linux系统鼠标偏移常见原因以及修复方案
linux·运维·游戏
用户0328472220703 天前
如何搭建本地yum源(上)
运维
A小辣椒5 天前
TShark:Wireshark CLI 功能
linux
A小辣椒5 天前
TShark:基础知识
linux
AlfredZhao5 天前
OCI 明明分配了 200G 系统盘,为什么 df 只看到 30G?
linux·oci