2

I have successfully installed Phusion passenger + Apache 2 + Rails 3.1 program + git on a linux Debian 6. I ran passenger-install-apache2-module and followed the configuration instructions. I followed also the setup instructions at https://help.ubuntu.com/community/RubyOnRails#Configure%20Apache

My program is in /var/www/myrailsproject and runs fine on webrick on my mac. When going to myhomepage.com (example) I only see directory listing. By preventing directory listing and setting Options -Indexes in < Document> tag in /etc/apache2/sites-available default or myhomepage.com I get an error on my website:

Forbidden You don't have permission to access / on this server. Apache/2.2.19 (Debian) Server at myhomepage.com Port 80

In /etc/apache2/apache.conf I added:

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**

In /etc/apache2/sites-available myhomepage.com:

< 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>

I think I have tried all possible combinations of values and variables in < Directory> (and < Directory />, < Directory /var/www> etc.)

the dafault looks like:

< 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>

So I wonder why my rails project is not being run, only directory listing. I do not have any index file in my project, routes.rb routes to root :to => 'static_pages#home' I think all permissions are as they should be.

1 Answer 1

0
< 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 >

Try this virtualhost.

It seems that the 'RailsBaseURI' is giving issues. For reference visit, Modrails Documentation

Thanks, TML.

You must log in to answer this question.