vi /usr/lib/systemd/system/nginx.service
[Unit]
Description=The NGINX HTTP and reverse proxy server
[Service]
Type=forking
ExecStartPre=/usr/servers/nginx/sbin/nginx -c /usr/servers/nginx/conf/nginx.conf -t
ExecStart=/usr/servers/nginx/sbin/nginx -c /usr/servers/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
重新加载服务配置
systemctl daemon-reload
添加为开机启动
systemctl enable nginx