nginx: [error] open() "/var/run/nginx/nginx.pid" failed (2: No such file or directory)

Maybe you don’t have a folder, just create it,
Or maybe it’s not running Nginx,
The first time I made an error: it did not run, so I directly executed the refresh configuration.
My second mistake:

Question:
After restarting the virtual machine, restarting Nginx will report an error: open() “/var/run/nginx/nginx.pid” failed (2: No such file or directory)
Solutions:
(1) Enter CD /usr/local/nginx/conf/ directory and edit the configuration file nginx.conf;
(2) Where there is a comment in the configuration file: # PID logs/nginx.pid;

(3) the annotation, go out and amended as: pid/usr/local/nginx/logs/nginx pid;

(4) Create the logs directory under /usr/local/nginx: mkdir /usr/local/nginx/logs
(5) start nginx service:/usr/local/nginx/sbin/nginx
 

Read More: