Nginx After installation, each time you start or restart the need to enter into operation in / usr / local / nginx, too much trouble, so adding Nginx to facilitate the management of the system services:
# 添加nginx.service
# vim /lib/systemd/system/nginx.service
[Unit]
Description=nginx service
After=network.target
[Service]
Type=forking
# 路径对应安装路径
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
After the addition is complete, you can use systemctl start nginx such as management, such as adding boot from the start:
systemctl enable nginx.service