艰难完成 nginx + puma 部署 rails 4的详细记录
2014-06-30 14:50
1956 查看
花了两周时间 Google 部署方法,找的的许多方法都没有用,最终被我用控制变量法,一条一条修改配置文件修改成功了。
首先是 /etc/nginx/vhosts/limlog.sloger.info.conf 和 config/puma.rb
# # /etc/nginx/vhosts/limlog.sloger.info.conf # upstream limlog { server unix:///tmp/limlog.sock; } server { listen 80; server_name limlog.sloger.info; root /srv/http/limlog.sloger.info/public; access_log /var/log/nginx/limlog-access.log; error_log /var/log/nginx/limlog-error.log info; location / { expires max; add_header Cache-Control public; proxy_redirect off; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://limlog; } location ~ ^/assets/ { expires 1y; gzip_static on; add_header ETag ""; add_header Cache-Control public; break; } }
#!/usr/bin/env ruby -w # # config/puma.rb # rails_env = ENV['RAILS_ENV'] || 'development' threads 4, 4 bind 'unix:///tmp/limlog.sock' pidfile '/tmp/limlog.pid' state_path '/tmp/limlog.state' activate_control_app
把 nginx 配置文件里的 root server_name upstream 修改成你的就行了,每个文件放在哪里,文件头部注释里面写了。
然后是修改 config/environmens/production.rb
18 行 false 改为 true
# Disable Rails's static asset server (Apache or nginx will already do this). config.serve_static_assets = true
29 行取消注释
# Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
然后是 app/controller/application_controller
第二行参数 with: :exception 去掉
protect_from_forgery
然手是 secret_key_base
我的做法是创建一个文件 env.sh
# 使用 rake secret 生成 key, 然后粘贴在 = 后面 export SECRET_KEY_BASE= # 下面可以 export 各种环境变量
启动
启动或者重启 nginx
导入环境变量 source env.sh
启动 rails bundle exec -C config/puma.rb -e production
现在就部署完毕了, 最令人头疼的 assets 也解决了~
您可能感兴趣的文章:
相关文章推荐
- 【Ruby on Rails Tutorial笔记】将第一个Rails应用部署到 Heroku实践遇到的问题及解决过程记录
- linux下安装部署solr5.4.0详细记录
- 极具个性化的【自定义日历】中式(纯干货)---超详细,记录你的学习计划与完成情况
- rails2 升级到 rails3 过程详细记录
- 极具个性化的【自定义日历】英式(纯干货)—超详细,记录你的学习计划与完成情况
- 极具个性化的【自定义日历】(预热篇)—超详细,记录你的学习计划与完成情况
- 使用passenger在Centos7部署Puma+Nginx+Ruby on Rails
- Ruby on Rails 终极部署方案 nginx+mina+puma
- 超详细从零记录Hadoop2.7.3完全分布式集群部署过程
- 超详细从零记录Hadoop2.7.3完全分布式集群部署过程
- 超详细从零记录Hadoop2.7.3完全分布式集群部署过程
- 【电子商务平台】Ofbiz研究学习详细记录——部署
- 超详细从零记录Hadoop2.7.3完全分布式集群部署过程
- 微信小程序详细图文教程-10分钟完成微信小程序开发部署发布
- 新手超详细记录:Docker for Windows打包制作tomcat镜像并部署java web项目
- 微信小程序详细图文教程-10分钟完成微信小程序开发部署发布
- jenkins+svn+maven+ssh 部署配置详细记录
- rails + capistrano + nginx + puma部署
- 记录从零开始在Ubuntu 16.04 上部署Ruby on rails 项目
- [置顶] rails2 升级到 rails3 过程详细记录