首页 > 其他 > 详细

centos 7 nginx启动脚本

时间:2017-02-17 01:05:06      阅读:366      评论:0      收藏:0      [点我收藏+]

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


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

[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-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 -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
  
[Install]
WantedBy=multi-user.target

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

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

systemctl disable nginx取消开机启动。

本文出自 “Kirito” 博客,请务必保留此出处http://aaronchou.blog.51cto.com/8981576/1898359

centos 7 nginx启动脚本

原文:http://aaronchou.blog.51cto.com/8981576/1898359

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!