windows下nginx的安裝及使用方法入門

來源:互聯網
上載者:User

標籤:服務   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的安裝及使用方法入門

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.