搜尋

nginx 安裝

Aug 08, 2016 am 09:24 AM
htmlhttpnbspnginxproxy

Nginx安裝部署

Nginx ("engine x") 是高效能的 HTTP  反向 Nginx 是由 Igor Sysoev 為俄羅斯訪問量第二的 Rambler.ru 站點開發的,第一個公開版本0.1.0發佈於2004104日。其將原始程式碼以類別BSD許可證的形式發布,因其它的穩定性、豐富的功能集、範例設定檔和低系統資源的消耗而聞名。 201161日,nginx 1.0.4發布。  

 

 

一般我們都需要先裝pcre

1.選定源碼目錄選定目錄 /usr/local/

 

2.

安裝PCRE

cd /usr/local/

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.gz

zxvf pcre-8.21.tar.gz

cd pcre-8.21

./configure

m

3.

安裝zlib

cd /usr/local/ 

wget 

http://zlib.net/zlib-1.2.8.tar.gz

. zlib-1.2.8./configure

make

make install

🜎

 

cd /usr/local /

wget 

http://www.openssl.org/source/openssl-1.0.1c.tar.gz

tar -zxvf openssl-1.0.1. /config

make

make install

 

5. Nginx 

一般有兩個版本,分別是穩定版和開發版,您可以根據您的目的來選擇這兩個版本的其中一個,下面是把

 Nginx 安裝到 /usr/local/nginx 

目錄下的詳細步驟:

/cd🜎 local/

wget 

http://nginx.org/download/nginx-1.2.8.tar.gz

tar -zxvf nginx-1.2.8.m-1.2.8. -1.2.8  ./configure 

--prefix=

/usr/local/nginx 

make --with-pcre=/usr /src/pcre-8.21 指的是

pcre-8.21 

的源碼路徑。

--with-zlib=/usr/src/zlib-1.2.7 

指的是zlib-1.2.7 的源碼路徑。

 

6.

啟動確保系統的

 80 

連接埠未被其他程式佔用,

檢查是否啟動成功:netstat -ano|grep 80 有結果輸入說明啟動成功

 

 

則表示 Nginx 已經安裝並運作成功。

 

7.

重啟/usr/local/nginx/sbin/nginx –s reload

cd /usr/local/ nginx/conf

vi nginx.conf

 

9.

常用設定韎

#啟動進程

,

通常設定成和cpu

的數量相等

worker_processes  4;

worker_processes  4;

PID檔案

pid /var/run/nginx.pid;

error_log  /var/log/nginx/error.log;

 

events {

        #epoll是多路復用IO(I/O Multiplexing) , 可以大幅提升nginx的表現use epoll;   worker process

進程的最大同時連結數

        worker_connections  10240; }#

設定http

伺服器,利用它的反向代理功能提供負載平衡支援   mime.types;

          default_type  application/octet-stream;

 

  /50x.html;

 

        index index.html index.shtml

        autoindex off;

 

     

        sendfile        on;

 

         tcp_nopush      on;

        tcp_nodelay     off;

 

        # output compression saves bandwidth

        gzip  off;

         #gzip_static on;

        #gzip_min_length  1k;

        gzip_http_version 1.0;

        gzip_comp_level 2;

        gzip_buffers         ip_proxied any;

        gzip_disable "MSIE [1-6].";

 application/x-javascript application/xml application/xml+rss text/javascript;

        #gzip_vary _name_in_redirect off;

 

#

設定負載均衡的伺服器清單

        upstream portals {

         ail_timeout=30s;

                  server 172.16.68.135:8082 max                       server 172.16.68.136:8082 max_fails=2 fail_timeout=30s;

                     s;

        }

 

   #       server 10.248.6.34:8090 max_fails=2 fail_timeout=30s;       

         #       server 10.248.6.45:8080 max_fails #}

 

        server {

               

#

偵聽8080                 listen       8080;🎠 27.0.0.1;

 

                                 error_page  403 = http://www.e100.cn/ ebiz/other/217/403.html;

                   error_page  404 = http://www.e100.cn/ebiz/other/218/404.html;

                   proxy_connect_timeout      90;

                   proxy_send_timeout         180 ;

                   proxy_read_timeout                       proxy_buffer_size 64k;

      

                   proxy_busy_buffers_size 128k;               client_header_buffer_size 16k;

                   large_client_header_buffers 4 64k;

 

                #proxy_send_timeout         3m;

                #proxy_read_timeout         3m;

                #proxy_buffer_size          4k;

                #proxy_buffers              4 32k;

 

                proxy_set_header Host $http_host;

  

                #proxy_hide_header Set-Cookie;

  

         #       if ($host != 'www.e100.cn' ) {

         #                 rewrite ^/(.*)$ http://www.e100.cn/$1 permano perman

         #       }

 

    位置/

 

                   位置中~ ^/resource/res/img/blue /space.gif {

                   proxy_pass

 

               地點= / {      /ebiz/event/ 517 .html 最後;

               }

 

 

 

                    位置= /ebiz/event/517.html {

                    add_header 變化接受編碼;

root /data/web/html;

                    過期10m;

               }

 

 

 

 

               位置= /check.html {

                    root /usr/local/nginx/html/;

;

               }

     

                    root/usr/local/nginx /html/;

                    過期1m;🎠 ess_log off;

                }      位置= /index.html {

                    編碼;

#

定義伺服器的預設網站根目錄位置

                             過期10m;

        向代理商存取名稱

                   位置中~ ^/ecps-portal/* {🎠  10m 後過期;

#重新導向叢集名稱

                    proxy      #proxy_pass http://172.16.68.134:8082;

                           location ~ ^ /fetionLogin/* {

                   # expire    proxy_pass http://portals;

                    #           }

 

                   #location  ~ ^/business/* {                                                                      

                #   # expires 10m;                                                                                

                #    proxy_pass http://172.16.68.132:8088;                                                                   

                #    #proxy_pass http://172.16. 68.134:8082;                                                       

                #}

 

                   location ~ ^/rsmanager/* {

                    expires 10m;

                    root /data/web/;

                    #proxy_pass http://rsm;

               }

#           location ~* (.*).(jpg|gif|htm|html|png|js|css )$  {

                         

#頁面快取時間為10分鐘

                                }

 

#

               location ~* ^/NginxStatus/ {                    stub_status on;                    access_log off;

                    allow 10.1.252.126;

                    allow 10.248.6.49;

                    allow 127.0.0.1;

                    deny all;

  

         #       error_page   405 =200 @405;🎠  

         #       {

        6.45:8080;

         #       }      access_log  /data/logs/nginx/access.log combined;

                    }

         server {

                listen       8082;

 

                server_name  _;

               location = /check.html {

                    root /usr/local/nginx/html /;

                    access_log off;

               }

                  

        }

         server {

                   listen       8088;

                   server_name  _;

                   location ~ ^ /* {

                   root /數據/web/b2bhtml/   access_log off;

         }                

         }

        服務器{

               聽著       9082;

                server_name  _;

 

        #        位置~ ^/資源/* {

#過期10m;

         #           root/data/c }

 

                       root /data/web/html/sysMaintain/;

                       if (!-f             重寫^/(.*)$ /sysMaintain.html 最後;

      

                }

        

}

以上就介紹了nginx的安裝,包含了方面的內容,希望對PHP教學有興趣的朋友有幫助。

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
PHP和Python:解釋了不同的範例PHP和Python:解釋了不同的範例Apr 18, 2025 am 12:26 AM

PHP主要是過程式編程,但也支持面向對象編程(OOP);Python支持多種範式,包括OOP、函數式和過程式編程。 PHP適合web開發,Python適用於多種應用,如數據分析和機器學習。

PHP和Python:深入了解他們的歷史PHP和Python:深入了解他們的歷史Apr 18, 2025 am 12:25 AM

PHP起源於1994年,由RasmusLerdorf開發,最初用於跟踪網站訪問者,逐漸演變為服務器端腳本語言,廣泛應用於網頁開發。 Python由GuidovanRossum於1980年代末開發,1991年首次發布,強調代碼可讀性和簡潔性,適用於科學計算、數據分析等領域。

在PHP和Python之間進行選擇:指南在PHP和Python之間進行選擇:指南Apr 18, 2025 am 12:24 AM

PHP適合網頁開發和快速原型開發,Python適用於數據科學和機器學習。 1.PHP用於動態網頁開發,語法簡單,適合快速開發。 2.Python語法簡潔,適用於多領域,庫生態系統強大。

PHP和框架:現代化語言PHP和框架:現代化語言Apr 18, 2025 am 12:14 AM

PHP在現代化進程中仍然重要,因為它支持大量網站和應用,並通過框架適應開發需求。 1.PHP7提升了性能並引入了新功能。 2.現代框架如Laravel、Symfony和CodeIgniter簡化開發,提高代碼質量。 3.性能優化和最佳實踐進一步提升應用效率。

PHP的影響:網絡開發及以後PHP的影響:網絡開發及以後Apr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP類型提示如何起作用,包括標量類型,返回類型,聯合類型和無效類型?PHP類型提示如何起作用,包括標量類型,返回類型,聯合類型和無效類型?Apr 17, 2025 am 12:25 AM

PHP類型提示提升代碼質量和可讀性。 1)標量類型提示:自PHP7.0起,允許在函數參數中指定基本數據類型,如int、float等。 2)返回類型提示:確保函數返回值類型的一致性。 3)聯合類型提示:自PHP8.0起,允許在函數參數或返回值中指定多個類型。 4)可空類型提示:允許包含null值,處理可能返回空值的函數。

PHP如何處理對象克隆(克隆關鍵字)和__clone魔法方法?PHP如何處理對象克隆(克隆關鍵字)和__clone魔法方法?Apr 17, 2025 am 12:24 AM

PHP中使用clone關鍵字創建對象副本,並通過\_\_clone魔法方法定制克隆行為。 1.使用clone關鍵字進行淺拷貝,克隆對象的屬性但不克隆對象屬性內的對象。 2.通過\_\_clone方法可以深拷貝嵌套對象,避免淺拷貝問題。 3.注意避免克隆中的循環引用和性能問題,優化克隆操作以提高效率。

PHP與Python:用例和應用程序PHP與Python:用例和應用程序Apr 17, 2025 am 12:23 AM

PHP適用於Web開發和內容管理系統,Python適合數據科學、機器學習和自動化腳本。 1.PHP在構建快速、可擴展的網站和應用程序方面表現出色,常用於WordPress等CMS。 2.Python在數據科學和機器學習領域表現卓越,擁有豐富的庫如NumPy和TensorFlow。

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
1 個月前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳圖形設置
1 個月前By尊渡假赌尊渡假赌尊渡假赌
威爾R.E.P.O.有交叉遊戲嗎?
1 個月前By尊渡假赌尊渡假赌尊渡假赌

熱工具

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )專業的PHP整合開發工具

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

將Eclipse與SAP NetWeaver應用伺服器整合。

SublimeText3 英文版

SublimeText3 英文版

推薦:為Win版本,支援程式碼提示!

Atom編輯器mac版下載

Atom編輯器mac版下載

最受歡迎的的開源編輯器

Dreamweaver Mac版

Dreamweaver Mac版

視覺化網頁開發工具