nginx [emerg] open() "/var/run/nginx/nginx.pid"
[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)
解决:在var/run/下建立一个文件夹命名为nginx,然后:
[root@localhost ~]# /usr/local/nginx/sbin/nginx
[root@localhost ~]# /usr/local/nginx/sbin/nginx -s reload
搞定!
经实验,每次虚拟机重启后,var/run/nginx,nginx这个文件夹都会被删除,搞得每一次都要去建立nginx这个文件夹。现在终于找到解决方法
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
修改:
[root@localhost ~]# 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文件夹下面,
然后把logs这个文件夹在conf下也拷贝一份
然后:
[root@localhost ~]# chmod 755 logs
[root@localhost ~]# chmod 755 nginx.pid
[root@localhost ~]# /usr/local/nginx/sbin/nginx
[root@localhost ~]# /usr/local/nginx/sbin/nginx -s reload