Railsで作成したサイトをAWSにデプロイし、いざIPアドレスで表示させようとした所500エラーになります。
あと一歩のところで1日が経過しました。この問題で考えられる原因はありますか?
現状について・・・
ec2
nginx
mysql
unicorn
は全て起動確認済です。
rake db:migrate RAILS_ENV=productionもできました。
プリコンパイルも完了しています。
環境について・・・
AWS
ec2
mac osx
ruby 2.3.1
rails 4.2.6
nginx/1.10.3
unicorn v5.2.0
mysql 5.5.56
初学者ですが何卒宜しくお願いします。
追記
nginx.error.logの内容↓
2017/07/25 04:15:20 [error] 2965#0: *3 connect() to unix:/var/www/rails/アプリ名/tmp/sockets/.unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 139.162.124.167, server: ipアドレス, request: "GET / HTTP/1.1", upstream: "http://unix:/var/www/rails/アプリ名/tmp/sockets/.unicorn.sock:/", host: "ipアドレス"
2017/07/25 23:41:18 [error] 29018#0: *33 open() "/usr/share/nginx/html/phpmyadmin/scripts/setup.php" failed (2: No such file or directory), client: 191.96.249.136, server: localhost, request: "GET /phpmyadmin/scripts/setup.php HTTP/1.0"
unicornの設定
unicorn.conf.rb↓
# set lets $worker = 2 $timeout = 30 $app_dir = "/var/www/rails/アプリ名" $listen = File.expand_path 'tmp/sockets/.unicorn.sock', $app_dir $pid = File.expand_path 'tmp/pids/unicorn.pid', $app_dir $std_log = File.expand_path 'log/unicorn.log', $app_dir # set config worker_processes $worker working_directory $app_dir stderr_path $std_log stdout_path $std_log timeout $timeout listen $listen pid $pid # loading booster preload_app true # before starting processes before_fork do |server, worker| defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! old_pid = "#{server.config[:pid]}.oldbin" if old_pid != server.pid begin Process.kill "QUIT", File.read(old_pid).to_i rescue Errno::ENOENT, Errno::ESRCH end end end # after finishing processes after_fork do |server, worker| defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection end
nginxの設定
アプリ名.conf↓
# log directory error_log /var/www/rails/アプリ名/log/nginx.error.log; access_log /var/www/rails/アプリ名/log/nginx.access.log; # max body size client_max_body_size 2G; upstream app_server { # for UNIX domain socket setups server unix:/var/www/rails/アプリ名/tmp/sockets/.unicorn.sock fail_timeout=0; } server { listen 80; server_name IPアドレス; # nginx so increasing this is generally safe... keepalive_timeout 5; # path for static files root /var/www/rails/アプリ名/public; # page cache loading try_files $uri/index.html $uri.html $uri @app; location @app { # HTTP headers proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://app_server; } # Rails error pages error_page 500 502 503 504 /500.html; location = /500.html { root /var/www/rails/アプリ名/public; } }
回答3件
あなたの回答
tips
プレビュー