Issues with Nginx
Probable reasons why Nginx does not start after reboot:
- Nginx is not added to autostart;
- Nginx starts before network services are loaded. In this case, it is necessary to delay the launch of Nginx.
How to add Nginx to autostart
- Execute the command:
systemctl enable nginx
- Reboot the server and check if Nginx is running:
service nginx status
How to delay the launch of Nginx
Method 1
- Replace the line /etc/systemd/system/multi-user.target.wants/nginx.service in the configuration file Nginx:
with:After=network.target remote-fs.target nss-lookup.target
After=network-online.target remote-fs.target nss-lookup.target
- Reboot the server and check if Nginx is running:
service nginx status
Method 2
- Add the string to the Nginx Service section configuration file /etc/systemd/system/multi-user.target.wants/nginx.service:
ExecStartPre=/bin/sleep <time>
Comments - Reboot the server and check if Nginx is running:
service nginx status