Home  >  Article  >  Operation and Maintenance  >  How to set nginx to start automatically at boot

How to set nginx to start automatically at boot

王林
王林forward
2020-11-09 15:49:054327browse

How to set nginx to start automatically at boot

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!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete