微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

centos 7 nginx启动脚本

centos7使用systemd代替之前的systemv的启动脚本,可以说更简单。不再需要编写一长段脚本。


复制以下内容到/usr/lib/systemd/system/Nginx.service

[Unit]
Description=Nginx-highperformancewebserver
Documentation=http://Nginx.org/en/docs/
After=network.targetremote-fs.targetnss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/Nginx/logs/Nginx.pid
ExecStartPre=/usr/local/Nginx/sbin/Nginx-t-c/usr/local/Nginx/conf/Nginx.conf
ExecStart=/usr/local/Nginx/sbin/Nginx-c/usr/local/Nginx/conf/Nginx.conf
ExecReload=/bin/kill-sHUP$MAINPID
ExecStop=/bin/kill-sQUIT$MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

即可使用systemctl start|stop|reload|restart Nginx 进行启动重启等操作。

systemctl enable Nginx即可实现开机启动。

systemctl disable Nginx取消开机启动。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。