Rails 程序未在 apache + Passenger 上运行 - 仅列出目录

Rails 程序未在 apache + Passenger 上运行 - 仅列出目录

我已成功在 Linux Debian 6 上安装了 Phusion Passenger + Apache 2 + Rails 3.1 程序 + git。我运行了 Passenger-install-apache2-module 并按照配置说明进行操作。我还遵循了以下安装说明:https://help.ubuntu.com/community/RubyOnRails#Configure%20Apache

我的程序在/var/www/myrails项目在我的 Mac 上的 webrick 上运行良好。我的主页(示例)我只看到目录列表。通过阻止目录列表并设置期权-指数< 文档 >标签/etc/apache2/站点可用 默认或者我的主页我的网站出现错误:

禁止访问 您无权访问此服务器上的 /。Apache/2.2.19 (Debian) 服务器位于 myhomepage.com 端口 80

在 /etc/apache2/apache.conf 中我添加了:

ServerName myhomepage.com  
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.8/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.8
PassengerRuby /usr/bin/ruby1.8**

在 /etc/apache2/sites-available 中我的主页

< VirtualHost *:80>

     ServerName myhomepage.com
     ServerAlias www.myhomepage.com
     DocumentRoot /var/www/myrailsproject/public
     ErrorLog /var/www/logs/error.log
     CustomLog /var/www/logs/access.log combined
     RailsEnv test
     RackEnv test
     RailsBaseURI /mayrailsproject
     < Directory /var/www/myrailsproject>
                Options -Indexes FollowSymLinks -MultiViews
                AllowOverride all
                Order allow,deny
                allow from all
     < /Directory>
     < Directory /var/www/myrailsproject/public>
         AllowOverride All
        Options -Indexes +FollowSymLinks MultiViews
        Order allow,deny
        Allow from all
     < /Directory>
        RailsSpawnMethod smart
        PassengerPoolIdleTime 1000
        RailsAppSpawnerIdleTime 0
        RailsFrameworkSpawnerIdleTime 0
        PassengerMaxRequests 5000
        PassengerStatThrottleRate 5
< /VirtualHost>

我想我已经尝试了 <Directory>(以及 <Directory />、<Directory /var/www> 等)中所有可能的值和变量的组合。

默认好像:

< VirtualHost *:80 >

        ServerName myhomepage.com
        RailsBaseURI /myrailsproject
        DocumentRoot /var/www/myrailsproject/public
        RackEnv test
        RailsEnv test
        < Directory /var/www/myrailsproject>
            Options -Indexes FollowSymLinks -MultiViews
            AllowOverride None
            Order deny,allow
            Deny from all
        < /Directory>

        <Directory /root/public/myrailsproject/public>
                Options -Indexes FollowSymLinks -MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    < Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    < /Directory>

< /VirtualHost>

所以我想知道为什么我的 rails 项目没有运行,只有目录列表。我的项目中没有任何索引文件,routes.rb 路由到根:到 => 'static_pages#home' 我认为所有权限都是应该的。

答案1

< VirtualHost *:80 >  
ServerName myhomepage.com  
ServerAlias www.myhomepage.com

DocumentRoot /var/www/myrailsproject/public

RailsEnv test  
RackEnv test  
RailsSpawnMethod smart  
PassengerPoolIdleTime 1000  
RailsAppSpawnerIdleTime 0  
RailsFrameworkSpawnerIdleTime 0  
PassengerMaxRequests 5000  
PassengerStatThrottleRate 5

< Directory /var/www/myrailsproject/public >  
      AllowOverride All  
      Options -Indexes +FollowSymLinks MultiViews  
      Order allow,deny  
      Allow from all  
< /Directory >

ErrorLog /var/www/logs/error.log  
CustomLog /var/www/logs/access.log combined  

< /VirtualHost >

尝试这个虚拟主机。

看来“RailsBaseURI”出了问题。有关参考信息,请访问:Modrails 文档

谢谢,TML。

相关内容