美文网首页
puma+nginx 服务器配置

puma+nginx 服务器配置

作者: 踩踩踩踩坑 | 来源:发表于2016-01-20 14:03 被阅读1037次

    参考

    https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-puma-and-nginx-on-ubuntu-14-04

    项目路径启动:

    bundle exec puma -e production -b unix:///www/learn_ground/shared/sockets/puma.sock

    1. database.yml 

    设置pool,puma默认为16

    pool: 16

    2. config/puma.rb

    # Min and Max threads per worker

    threads 0, 16

    #app_dir = File.expand_path("../..", __FILE__)

    #shared_dir = "#{app_dir}/shared"

    # Default to production

    #rails_env = ENV['RAILS_ENV'] || "production"

    environment "production"

    # Set up socket location

    bind "unix://www/hm_oa5.0/shared/sockets/puma.sock"

    # Logging

    stdout_redirect "/www/hm_oa5.0/shared/log/puma.stdout.log", "/www/hm_oa5.0/shared/log/puma.stderr.log", true

    # Set master PID and state locations

    pidfile "/www/hm_oa5.0/shared/pids/puma.pid"

    state_path "/www/hm_oa5.0/shared/pids/puma.state"

    activate_control_app

    #on_worker_boot do

    # require "active_record"

    #ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished

    # A#ctiveRecord::Base.establish_connection(YAML.load_file("/www/hm_oa5.0/config/database.yml")[rails_env])

    #end

    3.  /etc/nginx/sites-available

    upstream app {

    server unix:/www/hm_oa5.0/shared/sockets/puma.sock fail_timeout=0;

    }

    server {

    listen 80 default_server;

    listen [::]:80 default_server ipv6only=on;

    server_name server;

    root /www/hm_oa5.0/public;

    location ~ ^/assets/ {

    gzip_static on;

    expires max;

    add_header Cache-Control public;

    }

    try_files $uri/index.html $uri @app;

    location @app {

    proxy_set_header Host $http_host;

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_redirect off;

    proxy_pass http://app;

    proxy_set_header Connection '';

    proxy_http_version 1.1;

    chunked_transfer_encoding off;

    proxy_buffering off;

    proxy_cache off;

    }

    error_page 500 502 503 504 /500.html;

    client_max_body_size 4G;

    keepalive_timeout 10;

    }

    注意:

    /ect/  要有puma.conf

    /ect/init/  要有puma.conf,puma-manager.conf

    配置完后 重启nginx

    upstream app {

    # Path to Puma SOCK file, as defined previously

    server unix:/www/test_hm_oa/shared/sockets/puma.sock fail_timeout=0;

    }

    server {

    listen 9999;

    server_name  server;

    root /www/test_hm_oa/public;

    try_files $uri/index.html $uri @app;

    location @app {

    proxy_pass http://app;

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_set_header Host $http_host;

    proxy_redirect off;

    }

    error_page 500 502 503 504 /500.html;

    client_max_body_size 4G;

    keepalive_timeout 10;

    }

    相关文章

      网友评论

          本文标题:puma+nginx 服务器配置

          本文链接:https://www.haomeiwen.com/subject/nxllkttx.html