【问题标题】:Error in exposing ruby with passenger on a subdirectory (apache)在子目录 (apache) 上向乘客公开 ruby​​ 时出错
【发布时间】:2017-06-10 10:09:32
【问题描述】:

我在向乘客公开 ruby​​ 应用时遇到问题。 我已经在 localhost:3000 上安装并运行了所有东西,并且访问它没有问题。

但是,我想在端口 80 和特定地址上公开该站点:localhost/vocab

我将 Apache 虚拟主机设置为同时公开当前托管网站 (/var/www/html/Skosmos) 和 ruby​​ 应用程序(在 /var/www/html/vocab 中):

<VirtualHost *:80>
        <Directory /var/www/html/Skosmos>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

    ServerName domaine.fr/
    DocumentRoot /var/www/html/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

 Alias vocab/ /var/www/html/vocab/public
    <Location /vocab>
        PassengerBaseURI /vocab
        PassengerAppRoot /var/www/html/vocab/

    </Location>
    <Directory /var/www/html/vocab/public>
        Allow from all
        Options -MultiViews +FollowSymLinks
        # Uncomment this if you're on Apache >= 2.4:
        Require all granted
    </Directory>
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

但是如果我去 localhost/vocab 我得到这个错误

很抱歉,出了点问题。

如果您是应用程序所有者,请查看日志以获取更多信息

我的 apache2/error.log 报这个错误:

App 98561 stderr: Started GET "/vocab/en.html" for 193.50.232.240 at 2017-06-10 11:11:20 +0200
App 98561 stderr: Processing by FrontpageController#index as HTML
App 98561 stderr:   Parameters: {"lang"=>"en"}
App 98561 stderr:   Rendered frontpage/_title.html.erb (0.1ms)
App 98561 stderr:   Rendered frontpage/index.html.erb within layouts/application (1.3ms)
App 98561 stderr:   Rendered layouts/_modals.html.erb (0.1ms)
App 98561 stderr:   Rendered layouts/_navigation.html.erb (4.0ms)
App 98561 stderr: Completed 500 Internal Server Error in 9ms (ActiveRecord: 0.6ms)
App 98561 stderr:
App 98561 stderr: ActionView::Template::Error (Could not find table 'concepts'):
App 98561 stderr:     10:
App 98561 stderr:     11:     <div id="navbar" class="navbar-collapse collapse">
App 98561 stderr:     12:       <ul class="nav navbar-nav">
App 98561 stderr:     13:         <%= nav_items Iqvoc.navigation_items %>
App 98561 stderr:     14:       </ul>
App 98561 stderr:     15:
App 98561 stderr:     16:       <%= render "layouts/controls" %>
App 98561 stderr:   app/models/concept/skos/scheme.rb:39:in `instance'
App 98561 stderr:   app/models/ability.rb:7:in `initialize'
App 98561 stderr:   app/controllers/concerns/controller_extensions.rb:95:in `new'
App 98561 stderr:   app/controllers/concerns/controller_extensions.rb:95:in `current_ability'
App 98561 stderr:   lib/iqvoc/configuration/core.rb:47:in `block (2 levels) in <module:Core>'
App 98561 stderr:   app/helpers/navigation_helper.rb:29:in `instance_eval'
App 98561 stderr:   app/helpers/navigation_helper.rb:29:in `block in nav_items'
App 98561 stderr:   app/helpers/navigation_helper.rb:28:in `map'
App 98561 stderr:   app/helpers/navigation_helper.rb:28:in `nav_items'
App 98561 stderr:   app/views/layouts/_navigation.html.erb:13:in `_app_views_layouts__navigation_html_erb__2164981464980004636_37092560'
App 98561 stderr:   app/views/layouts/application.html.erb:28:in `_app_views_layouts_application_html_erb__1560657679497288447_36282840'

在 production.log 中没有记录任何问题(因为 logalhost:3000 完美运行)。
有什么解决方案、提示吗?

【问题讨论】:

  • 错误与模型不存在有关,你有名为concepts的表吗?
  • 检查您的数据库迁移。如果您使用的是 sqlite3,则可能需要执行 rake db:migrate,因为错误表明表 concepts 不存在。
  • 我发现它正在使用生产数据库,它是空的。我现在遇到了另一个问题,但是这个问题已经解决了。感谢您的帮助:)

标签: ruby apache passenger


【解决方案1】:

错误是由于使用了生产db(至少在localhost/vocab中),它是空的。

我通过命令行验证了:

sqlite3 db_name_production
.tables - 检查是否存在必要的表格
SELECT * FROM table_name; - 检查表格中的数据

CTRL + D 退出 sqlite3

然后将rails环境设置为生产模式并迁移表

RAILS_ENV=production rake db:migrate

RAILS_ENV=production rake assets:precompile(如果您提供静态资产)

并在生产模式下启动乘客

passenger start -e production

此解决方案在 localhost/vocab/ 上提供了正确的网站,但在提供文件 (manifest.css/js) 时仍然存在(至少我的情况)问题

【讨论】:

    猜你喜欢
    • 2014-11-01
    • 1970-01-01
    • 2017-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-03
    • 1970-01-01
    • 2016-11-19
    相关资源
    最近更新 更多