去nginx.org下載nginx 以nginx-1.8.1為例解壓到D盤nginx-1.8.1目錄
假設NGINX_HOME為D:\nginx-1.8.1
?
3種啟動途徑:
一、雙擊nginx.exe圖標,可見黑窗口一閃而過,啟動完畢。
二、命令行到nginx目錄,輸入nginx啟動。(注,此方式命令行窗口無任何提示,且被鎖定)
三、命令行到nginx目錄,輸入start nginx啟動,此方式不鎖定
?
命令匯總
nginx -s reload|reopen|stop|quit ?#重新加載配置|重啟|停止|退出 nginx
nginx -t ? #測試配置是否有語法錯誤
?
nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]
?
-?,-h ? ? ? ? ? : 打開幫助信息
-v ? ? ? ? ? ? ?: 顯示版本信息并退出
-V ? ? ? ? ? ? ?: 顯示版本和配置選項信息,然后退出
-t ? ? ? ? ? ? ?: 檢測配置文件是否有語法錯誤,然后退出
-q ? ? ? ? ? ? ?: 在檢測配置文件期間屏蔽非錯誤信息
-s signal ? ? ? : 給一個 nginx 主進程發送信號:stop(停止), quit(退出), reopen(重啟), reload(重新加載配置文件)
-p prefix ? ? ? : 設置前綴路徑(默認是:/usr/local/Cellar/nginx/1.2.6/)
-c filename ? ? : 設置配置文件(默認是:/usr/local/etc/nginx/nginx.conf)
-g directives ? : 設置配置文件外的全局指令
?
瀏覽地址http://localhost,即可訪問其默認頁面,即映射到NGINX_HOME/html/index.html
?
在NGINX_HOME下新建一個MySites文件夾 再新建兩個Test和First文件夾 并加入index.html文件
?
打開NGINX_HOME/conf/nginx.conf 增加下面配置
????server?{listen???????9000;server_name??localhost;location?/?{root???MySites/test;index??index.html?index.htm;}}server?{listen???????80;server_name??first1.zns.com??first2.zns.com;location?/?{root???MySites/first;index??index.html?index.htm;}}
?
修改了配置文件 必須執行重新加載配置文件命令?nginx -s reload
?
修改hosts文件 增加映射
127.0.0.1 ? first1.zns.com
127.0.0.1 ? first2.zns.com
?
瀏覽器訪問
http://localhost:9000/
http://first1.zns.com/
http://first2.zns.com/
?