最新消息:时间抓起来说是金子,抓不住就是流水。

Centos7添加nginx为系统服务

Nginx 老子黑牵翻 1223浏览 0评论

1、添加系统服务文件

$ vi /usr/lib/systemd/system/nginx.service
[Unit]
Description=Nginx Web Server
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=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
ExecQuit=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
  
[Install]
WantedBy=multi-user.target

2、重新加载系统配置

$ systemctl daemon-reload

3、用系统命令启停nginx服务

$ systemctl stop nginx
$ systemctl start nginx
$ systemctl reload nginx
$ systemctl restart nginx

转载请注明:LINUX服务器运维架构技术分享 » Centos7添加nginx为系统服务

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址