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

nginx服务器,在服务器关闭后,重启时,一直报如下错误:

[root@localhost sbin]# nginx: [emerg] open() "/var/run/nginx/nginx.pid" failed (2: No such file or directory)

解决方案:

  1. 进入 usr/local/nginx/conf/ 目录
 cd /usr/local/nginx/conf/
  1. 编辑配置文件nginx.conf
vi nginx.conf
  1. 在配置文件中有如下代码被注释:
#pid   logs/nginx.pid;
  1. 将注释去掉,即将#去掉,并修改为如下代码:
pid    /usr/local/nginx/logs/nginx.pid;
  1. 按Esc,输入如下代码,保存退出
:wq
  1. 在 /usr/local/nginx 目录下创建 logs 目录:
[root@localhost conf]# mkdir /usr/local/nginx/logs
  1. 启动nginx服务:
/usr/local/nginx/sbin/nginx

亲测成功!

你可能感兴趣的:(nginx)