【问题标题】:Rails application not loading after deploy to EC2 using Capistrano使用 Capistrano 部署到 EC2 后 Rails 应用程序未加载
【发布时间】:2016-02-27 01:14:10
【问题描述】:

我设置了一个 Amazon EC2 Ubuntu 14.04 实例,并按照 Passenger website 中的指南在 Apache 中使用 Capistrano 和Passenger 部署了我的 Rails 应用程序,尝试遵循所有说明,除了我有不同的应用程序名称和目录:/var/www/<my_app_name>

经过一些配置后,部署终于成功,当我尝试在我的应用程序文件夹中运行 Rails 控制台时,它工作正常,但是当我尝试通过 Web 浏览器中的 IP 地址访问我的应用程序时,它根本没有加载,浏览器返回 ERR_CONNECTION_TIMED_OUT错误。我已经重新启动了 Apache 几次,但它仍然无法正常工作。 Apache/Passenger 可能遗漏了某些内容或配置错误。

这是我来自 /var/log/apache2/error.log 的 Apache 错误日志:

[ 2015-11-24 14:20:25.7238 18152/7f3199f9d700 Ser/Server.h:444 ]: [UstRouter] Shutdown finished
[ 2015-11-24 14:20:25.7239 18152/7f31a07ab7c0 age/Ust/UstRouterMain.cpp:498 ]: Passenger UstRouter shutdown finished
[ 2015-11-24 14:20:25.7306 18230/7f2bca98a7c0 age/Wat/WatchdogMain.cpp:1276 ]: Starting Passenger watchdog...
[ 2015-11-24 14:20:25.7394 18233/7f7e579cd7c0 age/Cor/CoreMain.cpp:957 ]: Starting Passenger core...
[ 2015-11-24 14:20:25.7395 18233/7f7e579cd7c0 age/Cor/CoreMain.cpp:234 ]: Passenger core running in multi-application mode.
[ 2015-11-24 14:20:25.7408 18233/7f7e579cd7c0 age/Cor/CoreMain.cpp:707 ]: Passenger core online, PID 18233
[ 2015-11-24 14:20:25.7463 18242/7f9e135ba7c0 age/Ust/UstRouterMain.cpp:504 ]: Starting Passenger UstRouter...
[ 2015-11-24 14:20:25.7469 18242/7f9e135ba7c0 age/Ust/UstRouterMain.cpp:317 ]: Passenger UstRouter online, PID 18242
[Tue Nov 24 14:20:25.747329 2015] [mpm_event:notice] [pid 17566:tid 139962846635904] AH00489: Apache/2.4.7 (Ubuntu) Phusion_Passenger/5.0.21 configured -- resuming normal operations
[Tue Nov 24 14:20:25.747348 2015] [core:notice] [pid 17566:tid 139962846635904] AH00094: Command line: '/usr/sbin/apache2'

虽然我的 access.log 是空的。

这是我在/etc/apache2/sites-enabled/my_app.conf 中的 Apache 应用配置:

<VirtualHost *:80>
    ServerName <my_ip_address>

    # Tell Apache and Passenger where your app's 'public' directory is
    DocumentRoot /var/www/my_app/current/public

    PassengerRuby /usr/local/rvm/rubies/ruby-2.2.1/bin/ruby

    # Relax Apache security settings
    <Directory /var/www/my_app/current/public>
      Allow from all
      Options -MultiViews
      Require all granted
    </Directory>
</VirtualHost>

非常感谢任何帮助。提前致谢。

更新 1: 当我尝试使用passenger-status 查看Passenger 的状态时:

Phusion Passenger 目前不提供任何应用程序。

我试图通过触摸restart.txt 来让我的应用程序与Passenger 挂钩,如下所示:

$sudo touch /var/www/my_app/current/tmp/restart.txt

但它不起作用。

【问题讨论】:

    标签: ruby-on-rails apache amazon-ec2 capistrano passenger


    【解决方案1】:

    问题出在this SO question 中指出的实例设置上。 EC2 实例默认不允许公共 HTTP 访问:

    1. 点击ec2页面导航标签中的Instances

    2. 滚动浏览您的实例记录以查找安全组。点击安全组。

    3. 为安全组选择“入站”选项卡并确保存在以下规则。

      HTTP TCP 80 0.0.0.0/0

    【讨论】:

      猜你喜欢
      • 2013-09-29
      • 2013-03-12
      • 1970-01-01
      • 1970-01-01
      • 2019-04-27
      • 1970-01-01
      • 1970-01-01
      • 2011-06-28
      • 2017-10-10
      相关资源
      最近更新 更多