nginx路径:/etc/nginx/sbin
vi /etc/systemd/system/nginx.service
编辑文件
[Unit] Description=A high performance web server and a reverse proxy server After=network.target [Service] Type=forking ExecStart=/etc/nginx/sbin/nginx ExecReload=/etc/nginx/sbin/nginx -s reload ExecStop=/etc/nginx/sbin/nginx -s quit PIDFile=/run/nginx.pid PrivateTmp=true [Install] WantedBy=multi-user.target
开机自启:sudo systemctl enable nginx