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