在子目录(apache)上使用乘客暴露ruby时出错

时间:2017-06-10 10:09:32

标签: ruby apache passenger

我遇到了与乘客暴露红宝石应用程序的问题。 我安装了所有东西并在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完美运行) 任何解决方案,提示?

1 个答案:

答案 0 :(得分:0)

错误是由使用生产数据库(至少在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)