首頁 > 後端開發 > php教程 > linux nginx的安裝

linux nginx的安裝

WBOY
發布: 2016-08-08 09:23:10
原創
1075 人瀏覽過

安裝gcc

yum install gcc gcc-c++

先下載

pcre-8.12.tar.gzdn.com /8771933

tar -zxvf pcre-8.21.tar.gz

cd pcre-8.21

./configure

./configure提示權限不夠的話就用chmod 777 ./configure就可以了

如果在./configure的時候提示

error: in `/usr/local/src/pcre-8.12':configure: error: no acceptable C compiler found in $PATH

yum install gcc下載gcc


安裝 

http://zlib.net/zlib-1.2 .8.tar.gztar -zxvf zlib-1.2.8.tar.gz cd zlib-1.2.8

./configureinsta

安裝ssl 

cd /usr/local/wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz

tar -zxvf openssl-1.0.1c.tar.gz

./config

make

Nginx 一般有兩個版本,分別是穩定版和開發版,您可以根據您的目的來選擇這兩個版本的其中一個,以下是把 Nginx 安裝到 /usr/local/nginx 目錄下的詳細步驟:

 

 

  cd /usr/local/

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

tar -zxvvfm-1.

cd nginx-1.2.8  

./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/src/pcre-8.12 --with-http_ssl_with-http. openssl=/usr/local/src/openssl-1.0.1c

make

make install

 

--with-pcre=/usr/src/pcre-8.21 指的是pcre-8.21 的源碼路徑。

--with-zlib=/usr/src/zlib-1.2.7 指的是zlib-1.2.7 的源碼路徑。

 

6.啟動

確保系統的 80 連接埠未被其他程式佔用,

/us

檢查是否啟動成功:

netstat -ano|grep 80 有結果輸入說明啟動成功 

開啟瀏覽器存取此機器的 IP,如果瀏覽器出現  Welcome to nginin 

7.重啟

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

inx/conf

vi nginx.conf

9.常用設定

#nginx執行用戶和群組 cpu的數量相等

worker_processes  4;

#全域錯誤日誌及PID檔案

pid /var/run/nginx.pid;

pid /var/run/nginx.pid;

events {

        #epoll是多路復用IO(I/O Multiplexing)中的一種方式,但是僅用於linux2.6以上內核可以大大提高nginx的性能

;

                   #單一後台worker process進程的最大並發連結

}

#設定http伺服器,利用它的反向代理功能提供負載平衡支援

http {

        include       mime.types;

         error_page 400 403 500 502 503 504  /50x.html .shtml

 

        自動索引關閉;

 

              發送檔案        on;

 

     

     

         tcp_nopush      on;

   

        # 輸出壓縮節省頻寬

        on;

        #gzip_min_length  1k;

        gzip_http_version 1.0;

       zip_buffers  4 16k;

        gzip_proxied 任何;

          gzip_types  text /plain text/html text/css application/x-javascript application/xml application/xml+rss text/javascript;

              server_name_in_redirect off;

 

#設定負載平衡的伺服器清單

        上游入口網站{

     fails=2 failed_timeout=30s;

                  伺服器172.16.68.135:8082 _fails ;

                            回復伺服器172.16時。 68.136:8082 max_fails=2fail_timeout=30s;

                  服務器172.16.68.137:8082 max_fails=2fail_timeout=30s;

        }

 

        #上游溢出{

         #       服務器10.248. 6.34:8090 max_fails=2 failed_timeout=30s;       

         #90  0s;       

        #}

                                  而言聽8080埠

                聽        server_name  127.0.0.1;

 

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

                 地

                   proxy_connect_timeout      90;

                  proxy_send_timeout         180;

                    180;

                   proxy_read_timeout         180;

 

                   proxy_buffer_size 64k;

                   proxy_buffers 4 128k;

                   proxy_busy_buffers_size 128k ;

 

 

                             large_ client_header_buffers 4         3m;

                             # proxy_buffer_size 4k;

#proxy_buffers             4   proxy_set_header 主機$http_host;

               proxy    #proxy_hide_header Set-Cookie;

                 

#       如果( $主機!= 'www.e100.cn' ) {

           /$1 永久;

         #       }

 

 

                     排除皆為;

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

??位置 = / {

                  最後重寫 ^(.*)$        }

 

 

                   , /ebiz/event/517.html {🎠  編碼;

                    root /數據/網頁/ 過期10m;

               }

 

 

 

  

                    root /usr/local/nginx/html/;

}

 

                   root /usr/local/nginx/html/;

                          access_log off;

               }

 

 

                         add_header 改變接受編碼;

#定義伺服器的預設網站根目錄位置   web /html/ebiz;

                    過期10m;

#定義反向存取名稱

                         # 10m 後過期;

#重新導向資源名稱

                            #proxy_pass http://172.16.68.134   #proxy_pass http://172.16.68.134     位置~ ^/fetionLogin/* {

                  # 過期10m; proxy_pass http://portals;

                    #proxy_pass          }

 

                   #地點  ~ ^/商家/* {                                               #   # 10m 過期;                                                       🎠 172.16.68.132:8088;                                           

               68.134:8082;                                                       

                #}

 

                  位置~ ^/rsmanager/* {

                    過期10m;

                   root /data/web/;

                    #proxy_pass http:// rsm;

               }

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

                         

                         過期10m;

🎠    

#設定查看Nginx狀態的地址     

                ,* ^/NginxStatus/    stub_status   允許10.1.252.126;

                   

                    127.0.0.1;

🎠     

               }

       

         #       # 位置@405

     # proxy_pass http://10.248.6.45:8080;

         #                  access_log  /data/logs/nginx/access.log 合併;

      / error.log;

        }

           聽       8082;

            location = /check.html {

             / usr/local/nginx/html/;

access_log off;

}

}}

}

}

}}

}

line8088;

server_name _ ;;

                  位置中~ ^/* {

;

                   access_log   

         }

        

聽       9082;

                       #        位置中~ ^/資源/* {

#

               #           root /data/web/html/ ;

         #       }

 

                location  / {

                     root /data/web/html/sysMaintain/;

                       if (!-f $request_filename) {

                            rewrite ^/(.*)$ /sysMaintain.html last ;

                           

        }

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

相關標籤:
gcc
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板