<source id="4vppl"><ins id="4vppl"></ins></source>
<u id="4vppl"><sub id="4vppl"><label id="4vppl"></label></sub></u>
<object id="4vppl"></object>
  • <u id="4vppl"><li id="4vppl"><label id="4vppl"></label></li></u>

    <object id="4vppl"></object>
    <b id="4vppl"><sub id="4vppl"><tr id="4vppl"></tr></sub></b>

      <i id="4vppl"><thead id="4vppl"></thead></i>

      <thead id="4vppl"><li id="4vppl"><label id="4vppl"></label></li></thead>

      當前位置:首頁 > 網站舊欄目 > 學習園地 > 設計軟件教程 > nginx+mongrel cluster配置指南

      nginx+mongrel cluster配置指南
      2010-01-14 23:30:25  作者:  來源:
      安裝PCRE庫
      Ruby代碼 復制代碼
      1. $ ftp ftp.csx.cam.ac.uk   
      2. username: anonymous   
      3. > cd pub/software/programming/pcre/   
      4. > get pcre-7.4.tar.bz2   
      5.   
      6. > quit   
      7. $ tar -jxvf pcre-7.4.tar.bz2   
      8. $ cd pcre-7.4   
      9. $ ./configure   
      10. $ make  


      不需要安裝它,只是編譯nginx時需要用到而已。

      安裝nginx
      Ruby代碼 復制代碼
      1. $ wget http://sysoev.ru/nginx/nginx-0.5.32.tar.gz   
      2.   
      3. $ tar -zxvf nginx-0.5.32.tar.gz   
      4. $ cd nginx-0.5.32   
      5. $ ./configure –with-pcre=../pcre-7.4   
      6. $ make   
      7. $ sudo make install  


      配置nginx
      修改/usr/local/nginx/conf/nginx.conf:

      Ruby代碼 復制代碼
      1. user  someuser;   
      2. worker_processes  1;   
      3.   
      4. error_log logs/error.log  notice;   
      5.   
      6. pid logs/nginx.pid;   
      7.   
      8. events {   
      9.     worker_connections  1024;   
      10. }   
      11.   
      12. http {   
      13.     include       conf/mime.types;   
      14.     default_type  application/octet-stream;   
      15.   
      16.     access_log  logs/access.log;   
      17.   
      18.     sendfile        on;   
      19.     tcp_nopush     on;   
      20.   
      21.     keepalive_timeout  65;   
      22.     tcp_nodelay        on;   
      23.   
      24.     gzip  on;   
      25.     gzip_min_length  1100;   
      26.     gzip_buffers     4 8k;   
      27.     gzip_types       text/plain;   
      28.   
      29.     upstream mongrel {   
      30.         server 127.0.0.1:8100;   
      31.         server 127.0.0.1:8101;   
      32.         server 127.0.0.1:8102;   
      33.         server 127.0.0.1:8103;   
      34.     }   
      35.   
      36.     server {   
      37.         listen       80;   
      38.         server_name  your.server.com;   
      39.         location / {   
      40.             proxy_pass http://mongrel;   
      41.         }   
      42.   
      43.         root /home/your/app/path;   
      44.   
      45.         access_log  off;   
      46.         rewrite_log on;   
      47.   
      48.         location ~ ^/$ {   
      49.             if (-f /index.html){   
      50.                 rewrite (.*) /index.html last;   
      51.             }   
      52.             proxy_pass  http://mongrel;   
      53.             proxy_set_header   Host             $host;   
      54.         }   
      55.   
      56.         location / {   
      57.             if (!-f $request_filename.html) {   
      58.                 proxy_pass  http://mongrel;   
      59.             }   
      60.             rewrite (.*) $1.html last;   
      61.         }   
      62.   
      63.         location ~ .html {   
      64.             root /home/your/app/path;   
      65.         }   
      66.   
      67.         location ~* ^.+.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|   
      68.                                  exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mov)$ {   
      69.             root /home/your/app/path;   
      70.         }   
      71.         location / {   
      72.             proxy_pass  http://mongrel;   
      73.             proxy_redirect     off;   
      74.             proxy_set_header   Host             $host;   
      75.             proxy_set_header   X-Real-IP        $remote_addr;   
      76.             proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;   
      77.         }   
      78.     }   
      79. }  


      啟動 nginx
      $ sudo /usr/local/nginx/sbin/nginx
      配置啟動 mongrel cluster

      Ruby代碼 復制代碼
      1. $ cd /home/your/app/path   
      2. $ sudo mongrel_rails cluster::configure -e production \   
      3. -p 8100 -N 4 -c /home/your/app/path -a 127.0.0.1 \   
      4. –user mongrel –group mongrel   
      5. $ sudo mongrel_rails cluster::start  


      配置 HTTP 認證
      添加以下行到 nginx.conf:

      Ruby代碼 復制代碼
      1. location  /  {   
      2.     auth_basic            "Restricted";   
      3.     auth_basic_user_file  conf/htpasswd;   
      4. }  


      要生成htpasswd文件, 使用Apache附帶的htpasswd命令:

      $ sudo htpasswd -bc conf/htpasswd user pass

      關于htpasswd命令的使用,可使用’htpasswd -h’察看幫助。
      清理工作

      $ rm -rf pcre-7.4
      $ rm -rf nginx-0.5.32

      更新:如果遇到redirect_to重定向問題,請檢查你的nginx版本,老版本使用$http_host變量,因此應該對proxy_set_header做相應修改:

          proxy_set_header   Host             $host;


      安徽新華電腦學校專業職業規劃師為你提供更多幫助【在線咨詢
      国产午夜福三级在线播放_亚洲精品成a人片在线观看_亚洲自慰一区二区三区_久久棈精品久久久久久噜噜
      <source id="4vppl"><ins id="4vppl"></ins></source>
      <u id="4vppl"><sub id="4vppl"><label id="4vppl"></label></sub></u>
      <object id="4vppl"></object>
    1. <u id="4vppl"><li id="4vppl"><label id="4vppl"></label></li></u>

      <object id="4vppl"></object>
      <b id="4vppl"><sub id="4vppl"><tr id="4vppl"></tr></sub></b>

        <i id="4vppl"><thead id="4vppl"></thead></i>

        <thead id="4vppl"><li id="4vppl"><label id="4vppl"></label></li></thead>
        午夜精品福利波多野结衣 | 亚洲综合性色AⅤ一区二区三区 | 一级a一片久久久精品网 | 日韩欧美一区二区三区久久婷婷 | 一区二区三区四区激情另类 | 亚洲国产初高中女 |