Failed to parse PID from file ...
Error message
nginx.service: Failed to parse PID from file /usr/local/nginx/run/nginx.pid: Invalid argument
Step 1. Create a directory
Create a directory named nginx.service.d in /etc/systemd/system/:
mkdir /etc/systemd/system/nginx.service.d
cd /etc/systemd/system/nginx.service.d
Step 2. Print data to file
printf "[Service]\nExecStartPost=/bin/sleep 0.1\n" > override.conf
Step 3. Reload the daemon
Reload systemd manager configuration:
systemctl daemon-reload
This will rerun all generators, reload all unit files and recreate the entire systemd dependency tree.
Step 4. Restart NGINX
This line will restart NGINX for you:
systemctl restart nginx
The error should be fixed now.
An alternative workaround
Another workaround is removing the PIDFile option and adding the line:
ExecStopPost=/bin/rm -f /run/nginx.pid