經驗不在于年限,在于積累---專注互聯網軟件開發

          把工作當事業做,把項目當作品做!

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            55 Posts :: 0 Stories :: 66 Comments :: 0 Trackbacks
           

              最近Nginx比較火,聽說性能和穩定性都比目前市場占有率第一的Apache Web服務器高一個檔次。以前就想好好研究下Apache的,由于種種原因一直沒有去做。這次既然有更強大的替代品出現,決定好好研究研究。首先,來看看Nginx的簡介:

                 是一個高性能的 HTTP 反向代理 服務器,也是一個 IMAP/POP3/SMTP 代理服務器 Nginx 是由 Igor Sysoev 為俄羅斯訪問量第二的Rambler.ru 站點開發的,它已經在該站點運行超過四年多了。自Nginx 發布四年來,Nginx 已經因為它的穩定性、豐富的功能集、示例配置文件和低系統資源的消耗而聞名了。目前國內各大門戶網站已經部署了Nginx,如新浪、網易、騰訊等;國內幾個重要的視頻分享網站也部署了Nginx,如六房間、酷6、迅雷看看等。

          Nginx now hosts nearly 6% (13M) of all domains worldwide.

          最近在開發迅雷客服系統(http://help.xunlei.com/),搭建測試環境的時候突然想到Nginx,不妨當成一次學習和練手的機會。

                 目前Nginx的官網最新的穩定版本是nginx-0.7.65Linux下的源代碼文件包是:nginx-0.7.65.tar.gz

          一般編譯nginx時,都要先安裝pcrezlib等外部支持程序,然后編譯安裝nginx時指定這些外部支持程序的位置,這樣nginx在每次啟動的時候,就會去動態加載這些東西了。

          (1) 下載安裝外部支持庫

          cd /tmp
          wget ftp:
          //ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.01.tar.gz
          tar zxvf pcre-8.01.tar.gz
          cd pcre
          -8.01/
          .
          /configure
          make 
          && make install
          cd ..
          /
           

          (2) 安裝Nginx。將nginx-0.7.65.tar.gz解壓后,進行簡單的編譯安裝:

          tar zxvf nginx-0.7.65.tar.gz
          cd nginx
          -0.7.65/
          .
          /configure --prefix=/usr/local/nginx0765
          make 
          && make install
          cd 
          /usr/local/nginx0765
           

          (3) 啟動Nginx

          /usr/local/nginx0765/sbin/nginx

           

          Nginx的配置文件主要是:/usr/local/conf/nginx.conf

          客服系統的測試環境配置是:

          [root@game-13 conf]# vi nginx.conf

          #user  nobody;
          worker_processes  
          4;

          #error_log  logs
          /error.log;
          #error_log  logs
          /error.log  notice;
          #error_log  logs
          /error.log  info;

          #pid  logs
          /nginx.pid;


          events 
          {
               use epoll;
              worker_connections  
          1024;
          }



          http 
          {
              include       mime.types;
              default_type  application
          /octet-stream;

              #log_format  main  
          '$remote_addr - $remote_user [$time_local] "$request" '
              #                  
          '$status $body_bytes_sent "$http_referer" '
              #                  
          '"$http_user_agent" "$http_x_forwarded_for"';

              #access_log  logs
          /access.log  main;
              sendfile        on;
              #tcp_nopush     on;
              #keepalive_timeout  
          0;
              keepalive_timeout  
          65;

              #gzip  on;
              server 
          {
                  listen       
          80;
                  server_name  localhost;
                  #charset koi8
          -r;
                  #access_log  logs
          /host.access.log  main;
                  location 
          / {
                      root   html;
                      index  index.html index.htm;
                  }

                  #error_page  
          404              /404.html;
                  # redirect server error pages to the 
          static page /50x.html
                  #
                  error_page   
          500 502 503 504  /50x.html;
                  location 
          = /50x.html {
                      root   html;
                  }

              }


              server 
          {
                  listen       
          80;
                  server_name  help.xunlei.com;
                  #charset koi8
          -r;
                  #access_log  logs
          /host.access.log  main;
                  location 
          / {
                      root   
          /usr/local/htdocs/help.xunlei.com;
                      index  index.html index.htm;
                  }

              }

          }

           

          保存修改配置后,重新啟動Nginx服務器:

          /usr/local/nginx0765/sbin/nginx –s stop

          /usr/local/nginx0765/sbin/nginx

          這樣,配置Host,就可以訪問測試環境:http://help.xunlei.com


          (友情提示:本博文章歡迎轉載,但請注明出處:hankchen,http://www.aygfsteel.com/hankchen
          posted on 2010-05-12 20:09 hankchen 閱讀(860) 評論(0)  編輯  收藏 所屬分類: 服務器+Tomcat+Jetty

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 开封市| 商都县| 新龙县| 东台市| 苍梧县| 浦东新区| 达尔| 平潭县| 神木县| 邓州市| 彭山县| 桐乡市| 乌拉特后旗| 漯河市| 甘孜| 汾西县| 罗江县| 皮山县| 奉化市| 金寨县| 哈巴河县| 正蓝旗| 鹰潭市| 友谊县| 扶风县| 通城县| 宁夏| 甘洛县| 河北省| 乌鲁木齐县| 梅河口市| 辽中县| 齐齐哈尔市| 武乡县| 富源县| 砀山县| 泸定县| 东山县| 吉木萨尔县| 嘉禾县| 聂拉木县|