網上搜索安裝nginx的方法,按照步驟在 http://nginx.org/en/download.html 下載了安裝包,並配置了conf/nginx.conf,將nginx的根目錄添加進了環境變量path中;
打開命令行,進入 'D:\nginx-1.15.3\conf' 目錄,執行以下命令驗證配置文件的正確性:
html
nginx -t -c nginx.confnginx
結果提示錯誤:ui
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
而且運行以下命令:spa
nginx -t命令行
也是出現錯誤提示:code
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' ,以下運行命令:htm
D:\nginx-1.15.3> nginx -t -c conf\nginx.confci
則顯示配置文件正確:get
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
而且,運行命令:it
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