新建一个服务

1

vim/usr/lib/systemd/system/nginx.service
service部分请按照实际路径修改

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

[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