重启nginx报错,提示: 
[emerg] open() “/var/run/nginx/nginx.pid” failed (2: No such file or directory) 
解决:在var/run/下建立一个文件夹命名为nginx,然后: 
[[email protected] ~]# /usr/local/nginx/sbin/nginx 
[[email protected] ~]# /usr/local/nginx/sbin/nginx -s reload 

搞定! (亲测)

经博主实验,每次虚拟机重启后,var/run/nginx,nginx这个文件夹都会被删除,搞得每一次都要去建立nginx这个文件夹。现在博主终于找到解决方法 
[[email protected] ~]# vim /usr/local/nginx/conf/nginx.conf 
修改: 
[[email protected] ~]# vim /usr/local/nginx/conf/nginx.conf

user nobody;

worker_processes 1;

error_log logs/error.log;

error_log logs/error.log notice;

error_log logs/error.log info;

pid logs/nginx.pid;(把#删除)

然后:wq保存退出 
在/usr/local/nginx目录下建立logs文件夹,把/var/run/nginx/nginx.pid这里面的这个nginx.pid拷贝到这个logs文件夹下面, 
重启nginx报错:[emerg] open() "/var/run/nginx/nginx.pid" failed (2: No such file or directory)
重启nginx报错:[emerg] open() "/var/run/nginx/nginx.pid" failed (2: No such file or directory)

然后把logs这个文件夹在conf下也拷贝一份 
然后: 
[[email protected] ~]# chmod 755 logs 
[[email protected] ~]# chmod 755 nginx.pid 
[[email protected] ~]# /usr/local/nginx/sbin/nginx 
[[email protected] ~]# /usr/local/nginx/sbin/nginx -s reload 
现在OK了,关于这篇博文有任何问题,欢迎在下面留言!


相关文章:

  • 2021-08-24
  • 2021-07-01
  • 2022-12-23
  • 2021-05-11
  • 2022-12-23
  • 2021-06-05
猜你喜欢
  • 2021-12-14
  • 2022-12-23
  • 2022-01-05
  • 2022-01-13
  • 2021-08-16
  • 2021-10-10
相关资源
相似解决方案