Windows7安裝nginx后,'nginx -t -c nginx.conf' 命令出現 “could not open error log file: CreateFile() "logs/error.log" failed” 錯誤的原因


網上搜索安裝nginx的方法,按照步驟在 http://nginx.org/en/download.html 下載了安裝包,並配置了conf/nginx.conf,將nginx的根目錄添加進了環境變量path中;
打開命令行,進入 'D:\nginx-1.15.3\conf' 目錄,執行如下命令驗證配置文件的正確性:

nginx -t -c nginx.conf

結果提示錯誤:

nginx: the configuration file 'D:\nginx-1.15.3\conf/nginx.conf syntax is ok
nginx: [emerg] CreateDirectory() "'D:\nginx-1.15.3\conf/temp/client_body_temp" failed (3: The system cannot find the path specified)
nginx: configuration file 'D:\nginx-1.15.3\conf/nginx.conf test failed

並且運行如下命令:

nginx -t

也是出現錯誤提示:

nginx: [emerg] CreateFile() "'D:\nginx-1.15.3\conf/conf/nginx.conf" failed (3: The system cannot find the path specified)
nginx: configuration file 'D:\nginx-1.15.3\conf/conf/nginx.conf test failed

百思不得其解,后來在命令行上退出 conf 目錄,回到根目錄 'D:\nginx-1.15.3' ,如下運行命令:

D:\nginx-1.15.3> nginx -t -c conf\nginx.conf

則顯示配置文件正確:

nginx: the configuration file D:\nginx-1.15.3/conf\nginx.conf syntax is ok
nginx: configuration file D:\nginx-1.15.3/conf\nginx.conf test is successful

並且,運行命令:

D:\nginx-1.15.3> nginx -t

顯示nginx安裝正常

nginx: the configuration file D:\nginx-1.15.3/conf/nginx.conf syntax is ok
nginx: configuration file D:\nginx-1.15.3/conf/nginx.conf test is successful

nginx 常用命令:

驗證配置是否正確: nginx -t

查看Nginx的版本號:nginx -V

啟動Nginx:start nginx

快速停止或關閉Nginx:nginx -s stop

正常停止或關閉Nginx:nginx -s quit

配置文件修改重裝載命令:nginx -s reload


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM