標籤:服務 location ash index 報錯 art local col 解壓
nginx功能之一可以啟動一個本機伺服器,通過配置server_name和root目錄等來訪問目標檔案一. 下載http://nginx.org/ 下載後解壓
二. 修改設定檔
nginx設定檔在 nginx-1.8.0\conf\nginx.conf
http { gzip on; #靜態檔案 server { listen 80; server_name static.cnblog.com; location / { root G:/source/static_cnblog_com; } } #html檔案 server { listen 80; server_name 127.0.0.1 localhost; location / { root G:/source/html/mobile/dist; index index.html index.htm; } }}
如可以配置多個server,這樣訪問localhost即訪問到了 G:/source/html/mobile/dist 目錄, 還可以開啟gzip,壓縮html
三. 啟動 注意不要直接雙擊nginx.exe,這樣會導致修改配置後重啟、停止nginx無效,需要手動關閉工作管理員內的所有nginx進程 在nginx.exe目錄,開啟命令列工具,用命令 啟動/關閉/重啟nginx start nginx : 啟動nginxnginx -s reload :修改配置後重新載入生效nginx -s reopen :重新開啟記錄檔
nginx -t -c /path/to/nginx.conf 測試nginx設定檔是否正確
關閉nginx:
nginx -s stop :快速停止nginx
nginx -s quit :完整有序的停止nginx
如果遇到報錯:
bash: nginx: command not found
有可能是你再linux命令列環境下運行了windows命令,
如果你之前是允許 nginx -s reload報錯, 試下 ./nginx -s reload
或者 用windows系統內建命令列工具運行
windows下nginx的安裝及使用方法入門