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

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

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

    于吉吉的技術(shù)博客

    建造高性能門戶網(wǎng)

      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      65 隨筆 :: 6 文章 :: 149 評(píng)論 :: 0 Trackbacks
    nginx的官方網(wǎng)站是:http://www.nginx.org

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

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

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

    或直接使用yum install pcre,apt-get instll pcre進(jìn)行安裝

    登錄 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目錄和啟動(dòng)ssl,https模塊

    make

    make install

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

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

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

    ##啟動(dòng)進(jìn)程數(shù)
    worker_processes  8;
    worker_rlimit_nofile 
    10240;

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

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

    ##http服務(wù)器
    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;

    ##指定超時(shí)
    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;

    ##指定虛擬主機(jī)
    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;    ##設(shè)定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;    ##代理連接超時(shí)
    proxy_send_timeout      2m;    ##代理發(fā)送超時(shí)
    proxy_read_timeout      2m;    ##代理發(fā)送超時(shí)
    proxy_temp_file_write_size 2048m;##設(shè)定緩存文件夾大小
    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

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

    posted on 2010-11-30 12:45 陳于喆 閱讀(2635) 評(píng)論(0)  編輯  收藏 所屬分類: linux安裝配置
    主站蜘蛛池模板: 亚洲av永久无码精品三区在线4 | 久久亚洲中文字幕精品有坂深雪| 国产午夜无码精品免费看| 91亚洲国产在人线播放午夜| 成人av免费电影| sihu国产精品永久免费| 久久精品国产亚洲AV嫖农村妇女| 狼友av永久网站免费观看| 两性色午夜免费视频| 亚洲免费福利在线视频| 精品国产亚洲男女在线线电影 | 岛国av无码免费无禁网站| 三年片在线观看免费观看大全中国| 久久精品国产亚洲AV网站| 操美女视频免费网站| 中文在线免费观看| 亚洲三级在线观看| 国产亚洲av片在线观看16女人| 黄色片在线免费观看| 黄色片免费在线观看| 男女超爽视频免费播放| 亚洲美女精品视频| 中文字幕第一页亚洲| 午夜影视在线免费观看| 免费A级毛片无码A∨中文字幕下载 | 18禁美女黄网站色大片免费观看 | 男女拍拍拍免费视频网站| 中文字幕在线日亚洲9| 亚洲成AV人片在| 亚洲国产成人五月综合网 | 亚洲乱码国产乱码精品精| 国产小视频免费观看| 日日麻批免费40分钟日本的| 一本到卡二卡三卡免费高| 亚洲AV无码之国产精品| 亚洲成av人片在线看片| 亚洲AV无码国产在丝袜线观看| 亚洲AⅤ优女AV综合久久久| 处破痛哭A√18成年片免费| 免费观看无遮挡www的小视频| a毛片免费全部在线播放**|