CentOS7
Rails 6
Nginx
Puma
以上で本番環境を作って、いざ「bundle exec pumactl start」でアプリを起動させようとすると、
以下のようなエラーが出て起動しません。
uninitialized constant #<Class:#<Puma::DSL:0x00005628c8d4bd08>>::Rails config/puma.rb:40:in `_load_from' /home/user/app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/dsl.rb:43:in `instance_eval' /home/user/app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/dsl.rb:43:in `_load_from' /home/user/app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/configuration.rb:194:in `block in load' /home/user/app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/configuration.rb:194:in `each' /home/user/app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/configuration.rb:194:in `load' /home/user/app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/control_cli.rb:85:in `initialize' /home/user/app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/bin/pumactl:5:in `new' /home/user/app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/bin/pumactl:5:in `<top (required)>' /home/user/app/vendor/bundle/ruby/2.6.0/bin/pumactl:23:in `load' /home/user/app/vendor/bundle/ruby/2.6.0/bin/pumactl:23:in `<top (required)>' /home/user/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/cli/exec.rb:74:in `load' /home/user/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/cli/exec.rb:74:in `kernel_load' /home/user/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/cli/exec.rb:28:in `run' /home/user/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/cli.rb:465:in `exec' /home/user/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run' /home/user/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command' /home/user/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch' /home/user/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/cli.rb:27:in `dispatch' /home/user/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start' /home/user/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/cli.rb:18:in `start' /home/user/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/exe/bundle:30:in `block in <top (required)>' /home/user/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors' /home/user/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/exe/bundle:22:in `<top (required)>' /home/user/.rbenv/versions/2.6.4/bin/bundle:23:in `load' /home/user/.rbenv/versions/2.6.4/bin/bundle:23:in `<main>'
nginxの設定は以下の通りです。
nginx
1user user; 2worker_processes auto; 3error_log /var/log/nginx/error.log; 4pid /run/nginx.pid; 5 6include /usr/share/nginx/modules/*.conf; 7 8events { 9 worker_connections 1024; 10} 11 12http { 13 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 14 '$status $body_bytes_sent "$http_referer" ' 15 '"$http_user_agent" "$http_x_forwarded_for"'; 16 17 access_log /var/log/nginx/access.log main; 18 19 sendfile on; 20 tcp_nopush on; 21 tcp_nodelay on; 22 keepalive_timeout 65; 23 types_hash_max_size 2048; 24 25 include /etc/nginx/mime.types; 26 default_type application/octet-stream; 27 28 upstream app { 29 server unix:/home/user/app/tmp/sockets/puma.sock; 30 } 31 32 server { 33 listen 443; 34 server_name app.com; 35 root /usr/share/nginx/html; 36 client_max_body_size 70m; 37 38 ssl on; 39 ssl_certificate "/etc/nginx/ssl.crt/server.crt"; 40 ssl_certificate_key "/etc/nginx/ssl.key/server.key"; 41 ssl_session_cache shared:SSL:1m; 42 ssl_session_timeout 10m; 43 ssl_ciphers HIGH:!aNULL:!MD5; 44 ssl_prefer_server_ciphers on; 45 46 include /etc/nginx/default.d/*.conf; 47 48 location / { 49 proxy_pass https://app; 50 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 51 proxy_set_header Host $http_host; 52 proxy_redirect off; 53 } 54 55 error_page 404 500 502 503 504 /error.html; 56 location = /error.html { 57 root /usr/share/nginx/html; 58 } 59 60 }
また、config/puma.rbには
Puma
1bind "unix://#{Rails.root}/tmp/sockets/puma.sock" 2 3if "production" == ENV.fetch("RAILS_ENV") { "production" } 4 ssl_bind '0.0.0.0', '9292', { 5 key: "/etc/nginx/ssl.key/server.key", 6 cert: "/etc/nginx/ssl.crt/server.crt", 7 verify_mode: "none" 8 } 9end
という設定をしています。
対処法を教えてください。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。