问题

当启动nginx时出现如下错误

[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 
Logo

一起探索未来云端世界的核心,云原生技术专区带您领略创新、高效和可扩展的云计算解决方案,引领您在数字化时代的成功之路。

更多推荐