さくらのVPSでRailsアプリを公開したいのですが、自分なりに環境を構築しました。
しかしApacheの初期画面が表示されたままなのです。
Railsアプリを表示させるにはどうしたらいいのでしょうか?
現在の設定は以下のようにしています。
CentOS7
MariaDB
Ruby2.3.1
Rails5.1.3
Apache
Passenger
鍵認証設定完了
SSH接続
SSLの使用完了
/var/www/html/myapp #Railsアプリの設置完了
以下を実行
$ sudo yum install mysql-devel $ bundle install $ rails db:create RAILS_ENV=production $ rails db:migrate RAILS_ENV=production $ rails db:seed RAILS_ENV=production $ bundle exec whenever S crontab -l $ bundle exec whenever --update-crontab $ bundle exec rake assets:precompile RAILS_ENV=production
seedデータが投入されているか確認
$ rails c -e production #投入されていることを確認 OK
としたあとRailsサーバーを起動させます。
$ rails s -e production => Booting Puma => Rails 5.1.3 application starting in production on http://0.0.0.0:3000 => Run `rails server -h` for more startup options Puma starting in single mode... * Version 3.10.0 (ruby 2.3.1-p112), codename: Russell's Teapot * Min threads: 5, max threads: 5 * Environment: production * Listening on tcp://0.0.0.0:3000 Use Ctrl-C to stop
の状態です。
そしてブラウザでアクセスするとApacheの初期画面が表示されたままでRailsアプリが表示されないのです。
なにかが足りないのか間違っているのかが不明で困っています。
rails s のコマンドを実行で表示されるのが、http://0.0.0.0:3000 や tcp://0.0.0.0:3000 とか
表示されているのでそのあたりが原因じゃないかと思いますが、どこを修正すればいいのかわかりません。
どなたかご教示お願いいたします。
開発環境で$ rails s -e production でサーバーを起動した場合はproductionモードで動いてくれます。
追記
Apacheの設定は以下のようにしています。(コメントは削除しました)
/etc/httpd/conf/httpd.confの内容です。
ServerTokens Prod ServerSignature off ServerRoot "/etc/httpd" Listen 80 Include conf.modules.d/*.conf User apache Group apache ServerAdmin root@localhost <Directory /> AllowOverride none Require all denied </Directory> DocumentRoot "/var/www/html" <Directory "/var/www"> AllowOverride None # Allow open access: Require all granted </Directory> <Directory "/var/www/html"> Options FollowSymLinks AllowOverride None Require all granted </Directory> <IfModule dir_module> DirectoryIndex index.html </IfModule> <Files ".ht*"> Require all denied </Files> ErrorLog "logs/error_log" LogLevel warn <IfModule log_config_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common <IfModule logio_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio </IfModule> CustomLog "logs/access_log" combined </IfModule> <IfModule alias_module> ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" </IfModule> <Directory "/var/www/cgi-bin"> AllowOverride None Options None Require all granted </Directory> <IfModule mime_module> TypesConfig /etc/mime.types AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType text/html .shtml AddOutputFilter INCLUDES .shtml </IfModule> ServerTokens Prod ServerSignature off ServerRoot "/etc/httpd" Listen 80 Include conf.modules.d/*.conf User apache Group apache
回答2件
あなたの回答
tips
プレビュー