Nginx命令报错:nginx [alert] could not open error log file CreateFile()


问题

配置了 nginx 环境变量后,打开cmd运行 nginx ,发现 nginx 大部分命令都出错了

C:\Users\Administrator>nginx
nginx: [alert] could not open error log file: CreateFile() "logs/error.log" failed (3: The system cannot find the path specified)
2021/05/14 20:22:43 [emerg] 2024#11660: CreateFile() "C:\Users\Administrator/conf/nginx.conf" failed (3: The system cannot find the path specified)

C:\Users\Administrator>nginx -s stop
nginx: [alert] could not open error log file: CreateFile() "logs/error.log" failed (3: The system cannot find the path specified)
2021/05/14 20:22:52 [emerg] 2052#12692: CreateFile() "C:\Users\Administrator/conf/nginx.conf" failed (3: The system cannot find the path specified)

分析

无法打开错误日志文件logs/,可文件明明就在

查看配置文件nginx.conf

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

启动的文件是在当前目录下,也就是相对路径

解决

当我切回到 nginx 安装目录后再运行,就OK了

E:\Servce Program\nginx-1.18.0>nginx -s reload

E:\Servce Program\nginx-1.18.0>nginx -s stop


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM