nginx thin 部署rails3程序

来源:互联网 发布:贪心算法汽车加油问题 编辑:程序博客网 时间:2024/05/21 10:19

  1. 安装thin
    [ruby] view plaincopyprint?
    1. gem install thin  
    运行:
    [ruby] view plaincopyprint?
    1. thin start   
    测试是否能运行


  2. 生成配置文件
    [ruby] view plaincopyprint?
    1. thin config -C myapp.yml -s3 -p 3000  
    2. thin start -C myapp.yml  


  3. 配置nginx.conf文件
    [ruby] view plaincopyprint?
    1. upstream mongrel {  
    2.   server 127.0.0.1:3001;  
    3.   server 127.0.0.1:3002;  
    4.   server 127.0.0.1:3003;  
    5. }  
    6.   
    7. rver {  
    8.  listen 3000;  
    9.   
    10.  client_max_body_size 100M;  
    11.  root /var/www/sms/public;  
    12.  access_log  /var/www/sms/log/nginx.access.log;  
    13.   
    14.  if (-f $document_root/system/maintenance.html) {  
    15.    rewrite  ^(.*)$  /system/maintenance.html last;  
    16.    break;  
    17.  }  
    18.   
    19.  location / {  
    20.    proxy_set_header  X-Real-IP  $remote_addr;  
    21.   
    22.    # needed for HTTPS  
    23.    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;  
    24.    proxy_set_header Host $http_host;  
    25.    proxy_redirect false;  
    26.    proxy_max_temp_file_size 0;  
    27.   
    28.    if (-f $request_filename) {  
    29.      break;  
    30.    }  
    31.   
    32.    if (-f $request_filename/index.html) {  
    33.      rewrite (.*) $1/index.html break;  
    34.    }  
    35.   
    36.  if (-f $request_filename.html) {  
    37.      rewrite (.*) $1.html break;  
    38.    }  
    39.   
    40.    if (!-f $request_filename) {  
    41.      proxy_pass http://mongrel;  
    42.      break;  
    43.    }  
    44.  }  
    45.   
    46.  error_page   500 502 503 504  /500.html;  
    47.  location = /500.html {  
    48.    root   /var/www/sms/public;  
    49.  }  



  4. 启动thin集群
    [ruby] view plaincopyprint?
    1. thin start -C myapp.yml  

0 0
原创粉丝点击