Attribute nginx to SYSTEMd management

Time:2019-10-26
[[email protected] ~]# vim /usr/lib/systemd/system/nginx.service
[Unit]
Description = the nginx HTTP server daemon ා must be guarded or an error will be reported
#Description information
After=network.target remote-fs.target nss-lookup.target
#Specify other services needed before starting nginx, such as network.target, etc.
[Service]
Type=forking
#Type is the type of service, the service that only starts one main process is simple, and the service that needs to start several sub processes is forking
ExecStart=/usr/local/nginx/sbin/nginx
#Set the specific command to start after executing systemctl start nginx.
ExecReload=/usr/local/nginx/sbin/nginx -s reload
#Set the specific command to be executed after executing systemctl reload nginx.
ExecStop=/bin/kill -s QUIT ${MAINPID}
#Set the specific command to be executed after executing systemctl stop nginx.
[Install]
WantedBy=multi-user.target
[root @ centos7 ~] (systemctl daemon reload) load it several times.
Then nginx can be the same as public service!
[[email protected] ~]#systemctl start nginx
[[email protected] ~]#systemctl start renginx
[[email protected] ~]#systemctl reload nginx
[[email protected] ~]#systemctl stop nginx