Centos7 设置nginx 和 tomcat 自启动

Centos7 设置nginx 和 tomcat 自启动

nginx 的 安装地址

复制代码
/usr/local/tomcat/apache-tomcat-8.5.85/bin

tomcat 的 安装地址

复制代码
/usr/local/nginx/sbin/ 

自启动脚本

  • 创建脚本 vi /etc/systemd/system/tomcat_nginx_start.service
    写入脚本信息

    [Unit]
    Description=Startup script for Tomcat and Nginx
    After=network.target

    [Service]
    Type=forking
    ExecStart=/bin/bash -c 'cd /usr/local/tomcat/apache-tomcat-8.5.85/bin && ./startup.sh && cd /usr/local/nginx/sbin/ && ./nginx -s reload'
    User=root
    Restart=always

    [Install]
    WantedBy=multi-user.target

启用脚本

复制代码
systemctl daemon-reload
systemctl enable tomcat_nginx_start.service
systemctl start tomcat_nginx_start.service
systemctl status tomcat_nginx_start.service
systemctl restart tomcat_nginx_start.service 
相关推荐
运维行者_12 分钟前
企业无线网络监控的挑战与智能化演进趋势
大数据·运维·服务器·网络·数据库
2603_9552797043 分钟前
Cursor + GitOps:自动化运维新姿势
运维·自动化
Waay1 小时前
面试口述版:个人对 Prometheus 完整理解
运维·学习·云原生·面试·职场和发展·kubernetes·prometheus
三8441 小时前
文件查找/文件压缩/解压缩
linux·运维·服务器
小猪写代码1 小时前
Linux 管道(Pipeline)作业
linux·运维·服务器
桌面运维家2 小时前
如何用半缓存云桌面将服务器硬盘容量扩展至本地终端?
运维·服务器·缓存
激情的学姐2 小时前
【大型网站技术实践】初级篇:借助Nginx搭建反向代理服务器
运维·nginx
ai_coder_ai2 小时前
编写自动化脚本,在自己后端服务中使用Open Api进行设备相关操作
java·运维·自动化
spider_xcxc4 小时前
Redis 数据库高质量实践指南(一)
运维·数据库·redis·oracle·云计算
2501_943782354 小时前
【共创季稿事节】摇骰子:用 ArkTS 实现随机动画与交互反馈
运维·nginx·交互·harmonyos·鸿蒙·鸿蒙系统