首頁  >  文章  >  後端開發  >  Nginx - Windows下Nginx基本安裝與配置

Nginx - Windows下Nginx基本安裝與配置

WBOY
WBOY原創
2016-08-08 09:20:15941瀏覽
Nginx 是一個輕量級的高效能 Http WebServer,以事件驅動方式編寫,因此相比 Apache 而言,Nginx 更加穩定、性能更好,而且配置簡單,資源佔用較低。
1. 安裝Nginx 
1. 安裝Nginx 
從v0.7.52 開始,Nginx 開始發布Windows 版本的Nginx,你可以在其官方網站上面下載:http://nginx.net可,這裡解壓縮到c:nginx目錄。 
2. 啟動Nginx 
命令列進入c:nginx目錄,執行nginx.exe,啟動控制台視窗。預設啟用80埠。用過Tomcat的人都希望能在控制台看到啟動日誌,nginx的日誌卻不得不查看logs目錄下的對應log檔。
3. 訪問歡迎html頁 
在瀏覽器中訪問http://localhost,可以看到預設的歡迎頁. 
4.Nginx 。於是關閉控制台視窗。可是再造訪http://localhost依然有效。查看進程,發現nginx根本沒有被關閉。因此若要徹底關掉nginx,應該是 

Command代碼  

nginx -s stop  usage
     
  1. 或使用windows的taskkill指令: 

Command程式碼  
🠎
5. Ngnix常用配置

 

Nginx的所有配置都預設使用conf/nginx.conf文件,其地位相當於apache的httpd.conf文件。當運行nginx.exe暗含運行了nginx -c confnginx.conf. 如果想使用自己定義的conf文件如my.conf,命令為nginx -c confmy.conf. 
  1. 常用配置如下: 

Nginx .conf程式碼  
  1. http {  
  2.   server {  
  3.        listen  80;   
  4.     location / {  
  5. . 預設主頁目錄在nginx安裝目錄的html子目錄。         root   html;  
  6.         index  index.html index.htm;  
  7.         # 3. 沒有索引頁時,羅列文件和子目錄  
  8.         autoindex on;  
  9.         autoindex_exact_size on ;  
  10.         autoindex_localtime on;  
  11.      
  12.     location /tshirt {  
  13.     alias index.htm;  
  14.     }  
  15.   }     server {  
  16.     listen          80
  17.  server_name     www.emb.info;  
  18.     access_log emb.info/logs/access.log;  
  19.       index index.html;  
  20.       root  emb.info/htdocs;  
  21.     }  
  22.   }  }  32平台編譯版支援哪些模組。我這裡的結果是: 
  23. Log程式碼  
    1. nginx 版本:nginx/0.7.65  
    2. TLS ir=objs.msvc 8   
    3. --crossbuild= win32
    4. --with-debug --prefix=   
    5. --conf-path=conf/nginx.conf   
    6. -- http -log-path=logs/access.log   
    7. --error-log-path=logs/error.log   
    8. --sbin-path=nginx - 身體-temp-path=temp/client_body_temp   
    9. --http-proxy-temp-path=temp/proxy_temp   
    10. --http-fastgi-temp-tempgi-cm-cm-c與-cc-opt=-DFD_SETSIZE=
    11. 1024   
    12. --with-pcre=objs.msvc8/lib/pcre-7.9
    13. o/想法/8599999% -
    14. 0.9.8k   
    15. --with-openssl-opt=enable-tlsext   
    16. --with-zlib=objso.
    17. - -with-select_module   
    18. --with-http_ssl_module   
    19. --with-http_realip_module 
    20. --with-http_sub _module  
    21. --with- http_dav_module
    22. --with-http_stub_status_module   
    23. --with-http_flv_module  --with-http_random_index _module   
    24. --with-http_secure_link_module   
    25. - - with-mail   
    26. --with-mail_ssl_module   
    27. --with-ipv6  
    28. --with-ipv6  
    29. 3ache開發測試使用,對於產品平台,應該重新編譯自己想要的win32版本,或是在linux下使用更方便。 以上就介紹了Nginx - Windows下Nginx的基本安裝和配置,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn