Centos7添加nginx为系统服务

1、Centos7添加nginx为系统服务、

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 start  nginx.service

  systemctl stop  nginx.service

4、设置开机启动

  systemctl  enable nginx

  

 
 
posted @ 2020-07-05 12:57  小小仓鼠  阅读(1933)  评论(0编辑  收藏  举报