使用Apache和Passenger部署Rails应用程序后,显示页面不存在

3
我已经使用Apache2和Passenger部署了我的Rails应用程序。一切顺利进行,但是在部署后它显示页面不存在。我的应用程序名称是opengrok。
我的Apache配置位于/etc/apache2/sites-available/opengrok。
<VirtualHost *:80>
  ServerName localhost
  # !!! Be sure to point DocumentRoot to 'public'!
  DocumentRoot /var/www/opengrok/public
  <Directory /var/www/opengrok/public>
     # This relaxes Apache security settings.
     AllowOverride all
     # MultiViews must be turned off.
     Options -MultiViews
  </Directory>

那么出了什么问题呢?

日志显示

 I, [2013-09-16T13:00:41.656536 #6184]  INFO -- : Started GET "/" for 107.109.10.218 at         2013-09-16 13:00:41 +0600
 F, [2013-09-16T13:00:41.663573 #6184] FATAL -- :
 ActionController::RoutingError (No route matches [GET] "/"):
 actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
 actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
 railties (4.0.0) lib/rails/rack/logger.rb:38:in `call_app'
 railties (4.0.0) lib/rails/rack/logger.rb:21:in `block in call'
 activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `block in tagged'
 activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in `tagged'
 activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `tagged'
 railties (4.0.0) lib/rails/rack/logger.rb:21:in `call'
 actionpack (4.0.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
 rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
 rack (1.5.2) lib/rack/runtime.rb:17:in `call'
 activesupport (4.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
 railties (4.0.0) lib/rails/engine.rb:511:in `call'
 railties (4.0.0) lib/rails/application.rb:97:in `call'
 passenger (4.0.17) lib/phusion_passenger/rack/thread_handler_extension.rb:77:in  `process_request'
 passenger (4.0.17) lib/phusion_passenger/request_handler/thread_handler.rb:140:in `accept_and_process_next_request'
 passenger (4.0.17) lib/phusion_passenger/request_handler/thread_handler.rb:108:in `main_loop'
 passenger (4.0.17) lib/phusion_passenger/request_handler.rb:441:in `block (3 levels) in start_threads'
显示在我的主目录中
Prefix Verb URI Pattern                    Controller#Action
           root GET /                              opengrok_pages#index
opengrok_pages_show GET /opengrok_pages/show(.:format) opengrok_pages#show
opengrok_pages_load GET /opengrok_pages/load(.:format) opengrok_pages#load
opengrok_pages_text GET /opengrok_pages/text(.:format) opengrok_pages#text

你应该查看日志文件(Apache、Passenger、你的应用程序的)。 - Yevgeniy Anfilofyev
我已经更新了我的应用程序日志。 - sukanta
你能在应用程序主目录中运行 rake routes 吗?它会产生什么结果? - Yevgeniy Anfilofyev
我做了这个,但没有用 :( - sukanta
@YevgeniyAnfilofyev 我已经更新了我的问题,并附上了rake routes的结果。 - sukanta
将config/environments/production.rb中的config.consider_all_requests_local设置为true,我可以在生产环境中显示错误消息并查看实际问题。显然,在解决问题后要改回来。 - sukanta
1个回答

3
请在public后面添加斜杠“/”。
DocumentRoot /var/www/opengrok/public/

同时,目录根据需要进行设置。
<Directory /var/www/opengrok>

也要将您的Rails环境放置。
RailsEnv development

以下是我项目的配置文件之一,目前运行良好。
<VirtualHost _default_:80>
        ServerName pacerpro-alpha.hoverstate.com
        ServerAlias alpha.pacerpro.com
       # ServerName 23.22.184.199
        DocumentRoot /data/www/pacerpro_1.5/MyECF-Web-Application/current/public/
        ErrorLog "logs/pacerpro-alpha.hoverstate.com-error.log"
        RailsEnv development
        <Directory /data/www/pacerpro_1.5/MyECF-Web-Application/current>
                AllowOverride all
                Options -MultiViews
                Allow from all
        </Directory>

我认为安装 passenger-install-apache2-module 后的乘客推荐有误,但添加 RailsEnv development 解决了问题。 - Artem P

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接