The specific steps are as follows:
Create a new nginx.service file
vim /lib/systemd/system/nginx.service
Content:
[Unit] Description=nginx service After=network.target [Service] Type=forking ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf ExecReload=/usr/local/nginx/sbin/nginx -s reload ExecStop=/usr/local/nginx/sbin/nginx -s quit PrivateTmp=true [Install] WantedBy=multi-user.target
Start automatically after booting
systemctl enable nginx.service
Related recommendations: nginx tutorial
The above is the detailed content of How to set nginx to start automatically at boot. For more information, please follow other related articles on the PHP Chinese website!