前提・実現したいこと
AWS上のcloud9で開発しているruby on railsのページをEC2のパブリックIPでhttp経由でブラウザ上に表示したいです。
現在、NginsとUniconeを利用してデプロイしようとしているのですが、Nginxとunicornの起動時に以下のエラーが発生しております。
利用中の環境
ruby 2.6.3
rails 5.2.3
Nginxの設定 エラー
APP名(test_app)
Nginxの設定内容(etc/nginx/nginx.conf)
pid "/var/run/nginx.pid"; events { worker_connections 2048; } http { upstream unicorn { server unix:/home/ec2-user/environment/test-app/tmp/sockets/.unicorn.sock; } server { listen 80; server_name (publicIP); root /home/ec2-user/environment/test-app/; error_log /home/ec2-user/environment/test-app/log/nginx.log; include /etc/nginx/mime.types; location / { if (-f $request_filename) { break; } proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_pass http://unicorn; } } }
エラー内容
systemctl start nginx Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details. sudo nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: [emerg] open() "/home/ec2-user/environment/test-app/log/nginx.log" failed (2: No such file or directory) nginx: configuration file /etc/nginx/nginx.conf test failed
Unicornの設定 エラー
unicornの設定
config/unicorn.rb # unicorn.rb # set lets $worker = 2 $timeout = 30 $app_dir = "/home/ec2-user/environment/test-app/" #アプリの場所 $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
unicornのエラー
bundle exec unicorn_rails -E production -c config/unicorn.rb -D Traceback (most recent call last): 12: from /home/ec2-user/.rvm/gems/ruby-2.6.3/bin/ruby_executable_hooks:24:in `<main>' 11: from /home/ec2-user/.rvm/gems/ruby-2.6.3/bin/ruby_executable_hooks:24:in `eval' 10: from /home/ec2-user/.rvm/gems/ruby-2.6.3/bin/unicorn_rails:23:in `<main>' 9: from /home/ec2-user/.rvm/gems/ruby-2.6.3/bin/unicorn_rails:23:in `load' 8: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `<top (required)>' 7: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `new' 6: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:77:in `initialize' 5: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:77:in `new' 4: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:77:in `initialize' 3: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:84:in `reload' 2: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:84:in `instance_eval' 1: from config/unicorn.rb:12:in `reload' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:592:in `working_directory': config_file=config/unicorn.rb would not be accessible in working_directory=/home/ec2-user/environment/test-app (ArgumentError) master failed to start, check stderr log for details
色々と検索したり、コードも複数試したのですが毎回エラーになってしまいどうしようもない状況です。
宜しくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/06/10 05:56