<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    于吉吉的技術博客

    建造高性能門戶網

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      65 隨筆 :: 6 文章 :: 149 評論 :: 0 Trackbacks
    nginx的官方網站是:http://www.nginx.org

    Nginx ("engine x") 是一個高性能的 HTTP 和 反向代理 服務器,也是一個 IMAP/POP3/SMTP 代理服務器。 Nginx 是由 Igor Sysoev 為俄羅斯訪問量第二的 Rambler.ru 站點開發的,它已經在該站點運行超過兩年半了。Igor 將源代碼以類BSD許可證的形式發布。盡管還是測試版,但是,Nginx 已經因為它的穩定性、豐富的功能集、示例配置文件和低系統資源的消耗而聞名了。

    nginx的特性
    1.目前官方 Nginx 并不支持Windows,您只能在包括Linux,UNIX,BSD系統下安裝和使用
    2.Nginx 本身只是一個HTTP和反向代理服務器,它無法像Apache一樣通過安裝各種模塊來支持不同的頁面腳本,例如PHP、CGI等
    3.Nginx 支持簡單的負載均衡和容錯
    4.支持作為基本 HTTP 服務器的功能,例如日志、壓縮、Byte ranges、Chunked responses、SSL、虛擬主機等等,應有盡有

    安裝
    安裝nginx前需要確保系統中已經安裝PCRE包,PCRE library這個是HTTP Rewrite模塊,也即是url靜態化的包,到http://www.pcre.org下載最新的PCRE源碼包,

    或直接使用yum install pcre,apt-get instll pcre進行安裝

    登錄 http://www.nginx.org/en/download.html 下載最新的版本

    wget http://www.nginx.org/download/nginx-0.8.53.tar.gz

    tar zxvf nginx-0.8.53.tar.gz

    cd nginx-0.8.53

    ./configure --prefix=/usr/local/nginx --with-pcre=/home/download/pcre-8.01  --with-http_ssl_module --with-openssl=/home/download/openssl-1.0.0a --with-http_stub_status_module 

    ##指定pcre目錄和啟動ssl,https模塊

    make

    make install

    ##為什么Nginx的性能要比Apache高得多?這得益于Nginx使用了最新的epoll(Linux 2.6內核)和kqueue(freebsd)網絡I/O模型,而Apache則使用的是傳統的select模型。目前Linux下能夠承受高并發訪問的 Squid、Memcached都采用的是epoll網絡I/O模型,處理大量的連接的讀寫,Apache所采用的select網絡I/O模型非常低效

    配置
    編輯vi /usr/local/nginx/conf/nginx.conf,其中/usr/local/nginx為安裝路徑

    ##指定nginx的用戶名和用戶組
    user  nobody;

    ##啟動進程數
    worker_processes  8;
    worker_rlimit_nofile 
    10240;

    ##指定PID文件
    pid        logs/nginx.pid;

    ##指定工作模式和鏈接上限
    events {
        
    use epoll;
        worker_connections  
    10240;
    }

    ##http服務器
    http {
    include       mime.types;
    default_type  text
    /html;

    ##指定日志格式
    log_format  main  '$http_x_forwarded_for - $remote_user [$time_local] $request '
                      
    '"$status" $body_bytes_sent "$http_referer" '
                      
    '"$http_user_agent" "$http_x_forwarded_for"';

    ##指定accesslog
    access_log logs/nginx.log main;

    ##指定超時
    keepalive_timeout  300;

    ##開啟gzip模塊
    gzip  on;
    gzip_min_length  
    1000;
    gzip_buffers     
    4 8k;
    gzip_types       text
    /*;
    gzip_http_version 
    1.0;
    output_buffers   
    1 32k;
    postpone_output  
    1460;
    gzip_proxied     any;
    gzip_vary        on;

    ##指定請求的緩沖
    client_header_timeout   5m;
    client_body_timeout     5m;
    send_timeout            5m;
    sendfile                on;
    tcp_nopush              on;
    tcp_nodelay             off;
    client_header_buffer_size 16k;
    large_client_header_buffers 
    4 64k;
    server_names_hash_bucket_size 
    128;
    ssi on;
    ssi_silent_errors on;
    ssi_types text
    /shtml;

    ##指定虛擬主機
    server {
    listen      
    80;
    server_name _;
    server_name_in_redirect  off;

    location 
    / {
     root 
    /dev/null;
    }

    }

    ##指定include文件
    include servers/*.com;

    }


    新建proxy.conf

    proxy_set_header X-Forwarded-For $remote_addr;    ##設定header
    proxy_set_header RealIP $remote_addr;
    proxy_set_header Accept-Encoding ' ';
    proxy_hide_header Vary;    ##隱藏header
    add_header via_up $upstream_addr;
    proxy_connect_timeout   2m;    ##代理連接超時
    proxy_send_timeout      2m;    ##代理發送超時
    proxy_read_timeout      2m;    ##代理發送超時
    proxy_temp_file_write_size 2048m;##設定緩存文件夾大小
    proxy_buffer_size               256k; 
    proxy_buffers                   4 256k; 
    proxy_busy_buffers_size 512k; 

    proxy_ignore_client_abort off
    ;

    proxy_next_upstream error timeout invalid_header
    ;

    新建目錄/conf/servers,并新建配置文件test.com

    server {
            listen   
    80;
            server_name  245.test.com;
            root /home/htmlfile/test;

            location 
    = / {
                proxy_temp_path /var/www/cache
    ;
                index index.html index.htm;
            }


    }

    修改配置文件后,通過以下命令檢查配置是否正確

    /usr/local/nginx/sbin/nginx -t 

    the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    configuration file /usr/local/nginx/conf/nginx.conf test is successful

    啟動命令
    /usr/local/nginx/sbin/nginx 
    停止命令
    /usr/local/nginx/sbin/nginx  -s stop
    平滑重新加載配置文件
    kill -HUP `cat /usr/local/nginx/logs/nginx.pid
    添加到自啟動
    echo "/usr/local/nginx/sbin/nginx" >> /etc/rc.local

    posted on 2010-11-30 12:45 陳于喆 閱讀(2635) 評論(0)  編輯  收藏 所屬分類: linux安裝配置
    主站蜘蛛池模板: 日韩亚洲AV无码一区二区不卡| 亚洲码国产精品高潮在线| 亚洲导航深夜福利| 日本免费大黄在线观看| 亚洲宅男永久在线| 99在线热视频只有精品免费| 亚洲v高清理论电影| 桃子视频在线观看高清免费视频 | 亚洲第一成人影院| 色噜噜狠狠色综合免费视频 | 婷婷精品国产亚洲AV麻豆不片 | 免费无码AV电影在线观看| 亚洲av成人一区二区三区| 成人免费a级毛片| 亚洲成av人片在线天堂无| 免费h黄肉动漫在线观看| 乱人伦中文视频在线观看免费| 久久久无码精品亚洲日韩软件 | 久久久久久久久无码精品亚洲日韩| 午夜视频在线在免费| 美女被爆羞羞网站免费| 亚洲中文字幕第一页在线| 成人黄网站片免费视频| 亚洲中文字幕久久精品无码2021| 永久免费AV无码网站在线观看 | 深夜久久AAAAA级毛片免费看| 亚洲精品无码MV在线观看| 精品无码AV无码免费专区| 亚洲中文字幕一区精品自拍| 亚洲成A人片77777国产| 99免费在线观看视频| 亚洲精华液一二三产区| 亚洲热线99精品视频| 国产三级在线观看免费| h片在线播放免费高清| 亚洲日产2021三区| 亚洲男人天堂2020| 91精品免费国产高清在线| 国产成人无码免费网站| 亚洲国产美女视频| 美腿丝袜亚洲综合|