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
相关推荐
阿里云大数据AI技术25 分钟前
阿里云 EMR AI 助手正式发布:从问答工具到全栈智能运维助手
运维·人工智能
orion5718 小时前
Missing Semester Class1:course overview and introduction of shell
linux
SkyWalking中文站1 天前
认识 Horizon UI · 6/17:Trace 探索器
运维·监控·自动化运维
用户120487221611 天前
Linux驱动编译与加载
linux·嵌入式
火车叼位1 天前
写给初级开发者:SSL、SSH、HTTPS 与证书体系全解析
运维
用户805533698031 天前
Input 子系统架构:Core、Handler、Driver 三层是怎么协作的
linux·嵌入式
用户805533698031 天前
RK-Forge外设系列开篇 - 把板子从「能启动」变成「能用」:Ethernet/SPI/MMC 三个纯接线外设
linux·github·嵌入式
小猿姐2 天前
唯品会大规模数据库云原生实践:基于 KubeBlocks 管理数千实例的统一运维之路
运维·elasticsearch·云原生
七歌杜金房2 天前
我终于又有了自己的 Linux 电脑
linux·debian·mac
SkyWalking中文站2 天前
认识 Horizon UI · 5/17:3D 基础设施地图
运维·监控·自动化运维