1. 安裝跟配置
安裝:
下載地址:nginx: download
下載完成後,在指定位置解壓縮,不要直接雙擊nginx.exe。
配置:
server { listen 10700; #輸入端口號 server_name localhost; location / { root D:/nginx-1.16.1/html; #輸入包的地址 # 用於配合 browserHistory使用 try_files $uri $uri/ /index.html; index index.html index.htm; } }
2. 啓動nginx :
啓動nginx服務,啓動命令爲:start nginx,啓動時會一閃而過是正常的
修改配置執行下面命名:修改完成後保存,使用以下命令檢查一下配置文件是否正確,後面是nginx.conf文件的路徑,successful就說明正確了
d: cd D:\nginx-1.16.1 nginx -t -c /nginx-1.16.1/conf/nginx.conf
3. 出現下面標識啓動成功:
nginx: the configuration file D:/nginx-1.16.1/conf/nginx.conf syntax is ok
nginx: configuration file D:/nginx-1.16.1/conf/nginx.conf test is successful
4. 刷新配置:nginx -s reload
5. 出現錯誤:nginx: [error] invalid PID number "" in "D:\nginx-1.16.1/logs/nginx.pid"
原因:D:\nginx-1.16.1\logs文件夾下面缺少文件nginx.pid
解決:添加文件並且文件內部添加數字:395180
6. 出現錯誤:原因:那是系統在你修改配置文件的時候,將你的nginx關閉了
nginx: [error] OpenEvent("Global\ngx_reload_2144") failed (2: The system cannot find the file specified)
解決:start nginx
7. 關閉nginx服務使用以下命令,同樣也是一閃而過是正常的,看一下是否進程已消失即可
快速停止:nginx
-
s stop
完整有序的關閉:nginx
-
s quit