Handling nginx startup error Failed to read PID from file /run/nginx.pid

the cause of the problem

Because it takes a little time for nginx to start, and systemd reads the pid file before nginx finishes starting, which
causes the failure to read the pid

Solution

Let systemd wait for a while after executing the ExecStart command.
If your nginx takes longer to start, you can change the sleep time to a longer time.
Create a directory
mkdir -p /etc/systemd/system/nginx.service.d

Create a file override.conf in the new directory and enter the content

[Service]
ExecStartPost=/bin/sleep 0.1

然后
systemctl daemon-reload
systemctl restart nginx.service

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324433096&siteId=291194637