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