nginx的systemd管理方式设置
nginx每次都用脚本操作很不方便,我们可以给它设置systemd管理方式,来方便我们操作
1.将httpd的启动脚本复制给nginx (一般系统中自定义的启动脚本放在/etc/systemd/system/目录下)
[root@server1 sbin]# cp /usr/lib/systemd/system/httpd.service /etc/systemd/system/nginx.service
[root@server1 sbin]# vim /etc/systemd/system/nginx.service
修改如下:
1 [Unit]
2 Description=The Nginx HTTP Server
3
4 [Service]
5 Type=forking
6 PIDfile=/usr/local/nginx/logs/nginx.pid
7 ExecStart=/usr/local/nginx/sbin/nginx
8 ExecReload=/usr/local/nginx/sbin/nginx -s reload
9 ExecStop=/usr/local/nginx/sbin/nginx -s reload
10 PrivateTmp=true
11
12 [Install]
13 WantedBy=multi-user.target