Difficult to complete Nginx + Puma Deployment Rails 4 Detailed records _ruby topics

Source: Internet
Author: User

It took two weeks for Google to deploy the method, many of the methods are not used, and eventually I used the control variable method, a modified configuration file modification succeeded.

First,/etc/nginx/vhosts/limlog.sloger.info.conf and CONFIG/PUMA.RB.

# #
/etc/nginx/vhosts/limlog.sloger.info.conf
#
 
upstream Limlog {
  server   unix:///tmp/ Limlog.sock;
}
 
server {
  listen;
  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

Change the root server_name upstream in the Nginx configuration file to your line, where each file is placed, and the file head annotation is written.

Then modify the CONFIG/ENVIRONMENS/PRODUCTION.RB

18 Line false to True

# Disable Rails ' s static asset server (Apache or nginx'll already do this).
Config.serve_static_assets = True

29 Line Uncomment

# 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

And then the App/controller/application_controller.

The second line of arguments with:: Exception remove

Protect_from_forgery

And then the hand is secret_key_base

My practice is to create a file env.sh

# Use Rake secret to generate key, then paste in = behind
export secret_key_base=

# can export various environment variables

Start

Start or restart Nginx

Import environment variable Source env.sh

Start Rails bundle Exec-c CONFIG/PUMA.RB-E Production

Now the deployment is complete, the most vexing assets also solved ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.