国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

Nginx安裝部署

2019-11-09 15:31:28
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

Nginx安裝部署

Nginx ("engine x") 是一個(gè)高性能的 HTTP 和 反向代理 服務(wù)器,也是一個(gè) IMAP/POP3/SMTP 代理服務(wù)器。 Nginx 是由 Igor Sysoev 為俄羅斯訪問(wèn)量第二的 Rambler.ru 站點(diǎn)開(kāi)發(fā)的,第一個(gè)公開(kāi)版本0.1.0發(fā)布于2004年10月4日。其將源代碼以類(lèi)BSD許可證的形式發(fā)布,因它的穩(wěn)定性、豐富的功能集、示例配置文件和低系統(tǒng)資源的消耗而聞名。2011年6月1日,nginx 1.0.4發(fā)布。

 

一般我們都需要先裝pcre, zlib,前者為了重寫(xiě)rewrite,后者為了gzip壓縮。

1.選定源碼目錄

選定目錄 /usr/local/

 

cd /usr/local/

 安裝C++支持:yum install -y gcc-c++

2.安裝PCRE庫(kù)

cd /usr/local/

下載地址:pcre:http://sourceforge.NET/PRojects/pcre/files/ 

wget http://sourceforge.net/projects/pcre/files/pcre/8.35/pcre-8.35.tar.gz/download

tar -zxvf pcre-8.21.tar.gz

cd pcre-8.21

./configure

make

make install

 

3.安裝zlib庫(kù)

cd /usr/local/ 

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

tar -zxvf zlib-1.2.8.tar.gz cd zlib-1.2.8

./configure

make

make install

 

4.安裝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

make install

 

5.安裝nginx

 

Nginx 一般有兩個(gè)版本,分別是穩(wěn)定版和開(kāi)發(fā)版,您可以根據(jù)您的目的來(lái)選擇這兩個(gè)版本的其中一個(gè),下面是把 Nginx 安裝到 /usr/local/nginx 目錄下的詳細(xì)步驟:

 

cd /usr/local/

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

tar -zxvf nginx-1.2.8.tar.gz

cd nginx-1.2.8  

./configure --prefix=/usr/local/nginx 

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.啟動(dòng)

確保系統(tǒng)的 80 端口沒(méi)被其他程序占用,

/usr/local/nginx/sbin/nginx

 

檢查是否啟動(dòng)成功:

netstat -ano|grep 80 有結(jié)果輸入說(shuō)明啟動(dòng)成功

 

 

打開(kāi)瀏覽器訪問(wèn)此機(jī)器的 IP,如果瀏覽器出現(xiàn) Welcome to nginx! 則表示 Nginx 已經(jīng)安裝并運(yùn)行成功。

 

7.重啟

 /usr/local/nginx/sbin/nginx -s reload

 

8.修改配置文件

cd /usr/local/nginx/conf

vi nginx.conf

 

9.常用配置

#nginx運(yùn)行用戶(hù)和組

user    www www;  

#啟動(dòng)進(jìn)程,通常設(shè)置成和cpu的數(shù)量相等

worker_processes  4;

 

#全局錯(cuò)誤日志及PID文件

pid /var/run/nginx.pid;

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

 

events {

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

use epoll;

                   #單個(gè)后臺(tái)worker process進(jìn)程的最大并發(fā)鏈接數(shù)

        worker_connections  10240;

}

#設(shè)定http服務(wù)器,利用它的反向代理功能提供負(fù)載均衡支持

http {

        include       mime.types;

 

        default_type  application/octet-stream;

 

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

 

        index index.html index.shtml

 

        autoindex off;

 

         fastcgi_intercept_errors on;

 

        sendfile        on;

 

        # These are good default values.

        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  4 16k;

        gzip_proxied any;

        gzip_disable "MSIE [1-6]/.";

        gzip_types  text/plain text/html text/CSS application/x-javaScript application/xml application/xml+rss text/Javascript;

        #gzip_vary on;

 

        server_name_in_redirect off;

 

#設(shè)定負(fù)載均衡的服務(wù)器列表

        upstream portals {

                  server 172.16.68.134:8082 max_fails=2 fail_timeout=30s;

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

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

                  server 172.16.68.137:8082 max_fails=2 fail_timeout=30s;

        }

 

        #upstream overflow {

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

         #       server 10.248.6.45:8080 max_fails=2 fail_timeout=30s;       

        #}

 

        server {

                                     #偵聽(tīng)8080端口

                listen       8080;

                server_name  127.0.0.1;

 

                   #403、404頁(yè)面重定向地址

                   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         180;

 

                   proxy_buffer_size 64k;

                   proxy_buffers 4 128k;

                   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_max_temp_file_size 0;

                #proxy_hide_header Set-Cookie;

                  

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

         #                rewrite ^/(.*)$ http://www.e100.cn/$1 permanent;

         #       }

 

 

               location / {

                       deny all;

               }

 

                   location ~ ^/resource/res/img/blue/space.gif {

                    proxy_pass http://tecOpera;

               }

 

               location = / {

                   rewrite ^(.*)$  /ebiz/event/517.html last;

               }

 

 

 

                   location = /ebiz/event/517.html {

                    add_header Vary Accept-Encoding;

                    root /data/web/html;

                    expires 10m;

               }

 

 

 

 

               location = /check.html {

                    root /usr/local/nginx/html/;

                    access_log off;

               }

 

               location = /50x.html {

                    root /usr/local/nginx/html/;

                    expires 1m;

                    access_log off;

               }

 

 

              location = /index.html {

                       add_header Vary Accept-Encoding;

#定義服務(wù)器的默認(rèn)網(wǎng)站根目錄位置

                    root /data/web/html/ebiz;

                    expires 10m;

               }

#定義反向代理訪問(wèn)名稱(chēng)

                   location ~ ^/ecps-portal/* {

                   # expires 10m;

#重定向集群名稱(chēng)

                    proxy_pass http://portals;

                    #proxy_pass http://172.16.68.134:8082;

               }

 

                   location ~ ^/fetionLogin/* {

                   # expires 10m;

                    proxy_pass http://portals;

                    #proxy_pass http://172.16.68.134:8082;

                }

 

                   #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;

               }

#定義nginx處理的頁(yè)面后綴

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

                            root /data/web/html/;

#頁(yè)面緩存時(shí)間為10分鐘

                         expires 10m;

                   }

 

#設(shè)定查看Nginx狀態(tài)的地址     

               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;

         #       location @405

         #       {

         #                proxy_pass http://10.248.6.45:8080;

         #       }  

 

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

               error_log   /data/logs/nginx/error.log;

        }

         server {

                listen       8082;

 

                server_name  _;

               location = /check.html {

                    root /usr/local/nginx/html/;

                    access_log off;

               }

                  

        }

         server {

                   listen       8088;

                   server_name  _;

                   location ~ ^/* {

                   root /data/web/b2bhtml/;

                   access_log off;

         }                

         }

        server {

                listen       9082;

                server_name  _;

 

        #        location ~ ^/resource/* {

        #            expires 10m;

         #           root /data/web/html/;

         #       }

 

                location  / {

                     root /data/web/html/sysMaintain/;

                       if (!-f $request_filename) {

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

                           }

                }

        }

 

}


發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 皋兰县| 仪陇县| 伊通| 启东市| 麦盖提县| 岳阳市| 青浦区| 辉县市| 大荔县| 福海县| 酉阳| 克拉玛依市| 景德镇市| 孝感市| 兴安盟| 阜新市| 乐亭县| 贵德县| 弥渡县| 新邵县| 石河子市| 铜鼓县| 特克斯县| 都昌县| 额敏县| 洮南市| 台中县| 福安市| 巴青县| 永德县| 平武县| 承德县| 临漳县| 彭水| 宕昌县| 买车| 贡觉县| 舒城县| 巴彦县| 沈阳市| 镇原县|