欢迎来到cool的博客
7

Music box

Click to Start

点击头像播放音乐
新博客链接

Rails项目使用thin+nginx部署

        1、git pull

    2、bundle

        3、config目录下配置datebase.yml 和 log4r.yml

    4mkdir log
    5、bundle exec rake db:create
    6、bundle exec rake db:migrate

thin     1、在config目录下配置thin.yml文件(注意按情况修改chdir和port还有servers等)

chdir: /opt/app/hotel_system
environment: production
address: 0.0.0.0
port: 6666
timeout: 30
max_conns: 1024
max_persistent_conns: 100 
require: []
wait: 30
servers: 2
daemonize: true

 2、启动thin

bundle exec thin start -C config/thin.yml  (stop/restart)

nginx     1、配置nginx文件 (/etc/nginx/config.yml  或者 /etc/nginx/sites-enabled/特定文件)

  server {
          listen       3456;
          server_name  duxiao.siwei.tech;
          client_max_body_size       500m;
          charset utf-8;
          location / { 
              proxy_pass          http://duxiao_servers;
              proxy_redirect      default;
              proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header    X-Real-IP $remote_addr;
              proxy_set_header    Host $http_host;
              proxy_next_upstream http_502 http_504 error timeout invalid_header;
          }
  }
  upstream duxiao_servers{
         server localhost:5801;
         #server localhost:3701;
  }

  3、重启nginx

sudo nginx -s stop
sudo nginx 

加载js和css

bundle exec rake assets:precompile RAILS=production

返回列表