nginx: [error] open() “/usr/local/nginx/logs/nginx.pid“ failed (2: No such file or directory)

nginx: [error] open() “/usr/local/nginx/logs/nginx.pid“ failed (2: No such file or directory)

问题

当启动nginx时出现如下错误

java">[root@iZuf65h6i43ltlzhqolumyZ nginx]# ./sbin/nginx
nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (2: No such file or directory)
2024/02/17 13:18:36 [notice] 2828#0: signal process started
2024/02/17 13:18:36 [error] 2828#0: open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)

解决方案

【1】nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (2: No such file or directory) 问题可以通过创建logs文件解决。
【2】nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)是因为nginx.conf中的nginx.pid被注释了,进入nginx.conf目录编辑

[root@iZuf65h6i43ltlzhqolumyZ nginx]# vi conf/nginx.conf 

pid的注释放开即可

pid        logs/nginx.pid;

把注释取消掉,再重新启动NginxOK

【3】没有指定配置目录:输入来使用指定nginx.conf文件的方式重启nginx(首先保证上面第一种情况的pid没有被注释,否则可能前两次能打开,但是以后还是会报错的)

[root@iZuf65h6i43ltlzhqolumyZ nginx]# sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 
转载请说明出处内容投诉
CSS教程_站长资源网 » nginx: [error] open() “/usr/local/nginx/logs/nginx.pid“ failed (2: No such file or directory)

发表评论

欢迎 访客 发表评论

一个令你着迷的主题!

查看演示 官网购买