Forbidden error on rails app with Passenger and Apache

I run a rails app at /home/vincent/Documents/vincentApp/ . The app runs fine with WEBrick on localhost:3000. However, I am getting a Forbidden error when accessing the app on Apache on port 80. I suspect this is more of a problem with my Apache config than with Rails or Passenger. The configs are below. Please help. Thanks.

I have Passenger installed.

The following is in /etc/apache2/apache2.conf:

# Passenger LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-2.2.8/ext/ apache2/mod_passenger.so PassengerRoot /var/lib/gems/1.8/gems/passenger-2.2.8 PassengerRuby /usr/bin/ruby1.8

I run a rails app at /home/vincent/Documents/vincentApp/ . The app

runs fine with WEBrick on localhost:3000. However, I am getting a

Forbidden error when accessing the app on Apache on port 80. I

suspect this is more of a problem with my Apache config than with

Rails or Passenger. The configs are below. Please help. Thanks.

I have Passenger installed.

The following is in /etc/apache2/apache2.conf:

Passenger

LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-2.2.8/ext/

apache2/mod_passenger.so

PassengerRoot /var/lib/gems/1.8/gems/passenger-2.2.8

PassengerRuby /usr/bin/ruby1.8

=======

The following is the content of the file /etc/apache2/sites-enabled/

default

<VirtualHost *:80>

    ServerAdmin webmaster@localhost

DocumentRoot /home/vincent/Documents/vincentApp/public

    <Directory />

            Options FollowSymLinks

            AllowOverride None

    </Directory>

<Directory “/home/vincent/Documents/vincentApp/public/”>

Options FollowSymLinks Indexes

AllowOverride None

            Order allow,deny

            allow from all
    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 /var/log/apache2/error.log



    # Possible values include: debug, info, notice, warn, error, crit,

    # alert, emerg.

    LogLevel warn



    CustomLog /var/log/apache2/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](http://127.0.0.0/255.0.0.0) ::1/128

</Directory>

=======

passenger status:

sudo /var/lib/gems/1.8/bin/passenger-status

----------- General information -----------

max = 6

count = 0

active = 0

inactive = 0

Waiting on global queue: 0

----------- Domains -----------

=======

Apache log:

[Sun Jan 17 18:35:30 2010] [error] [client ::1] (13)Permission denied:

access to / denied

You can try adding the following after the second Directory block:

RailsBaseURI /

Next, I would verify that ‘Allow from’ is correct. I have used the following

without fail:

Allow from all

Good luck,

-Conrad

Learn by Doing wrote:

DocumentRoot /home/vincent/Documents/vincentApp/public   <Directory />     Options FollowSymLinks     AllowOverride None   </Directory> <Directory "/home/vincent/Documents/vincentApp/public/"> Options FollowSymLinks Indexes AllowOverride None     Order allow,deny     allow from all </Directory>

On the second Directory, you should have:

<Directory /home/vincent/Documents/vincentApp/public//>   Options Indexes FollowSymLinks MultiViews   AllowOverride None   Order allow,deny   allow from all </Directory>

You have quotes surrounding your directory which you can remove. You should also add Indexes and MultiViews here as well. Just copy and paste what I placed in there.

  CustomLog /var/log/apache2/access.log combined

After this line place:

CustomLog /var/log/apache2/access.log combined ServerSignature On

Besides not having any expiresheaders etc. placed in, everything else is fine.

Correcting one syntax error:

<Directory /home/vincent/Documents/vincentApp/public/>   Options Indexes FollowSymLinks MultiViews   AllowOverride None   Order allow,deny   allow from all </Directory>

No second forward slash - apologies.

Condrad and Alpha, Thank you for your help. I am still getting the error. Below is the edited section of /etc/apache2/sites-enabled/ default :

<VirtualHost *:80>   ServerAdmin webmaster@localhost

DocumentRoot /home/vincent/Documents/vincentApp/public   <Directory />     Options FollowSymLinks     AllowOverride None   </Directory> <Directory /home/vincent/Documents/vincentApp/public/>   Options Indexes FollowSymLinks MultiViews    AllowOverride None    Order allow,deny    Allow from all </Directory>

RailsBaseURI /

  ...

  CustomLog /var/log/apache2/access.log combined   ServerSignature On

...

</VirtualHost>

Thanks.

BTW, if it is relevant at all, every time I modified the config files, I did restart apache. But that did not help. I am running Apache 2.2.12 on Ubuntu 9.10. Thanks.

Hi all,

It starts working for some reason after I use "git clone local" instead of "scp" to create the vincentApp directory. However, the directory git creates only gives write permission to root (must be a consequence of gitosis). I had to chmod a+w to the log and tmp folder before the app shows through Apache. Is there a better way than to chmod every time I deploy to production?

Thanks.

Hi all,

It starts working for some reason after I use "git clone local" instead of "scp" to create the vincentApp directory. However, the directory git creates only gives write permission to root (must be a consequence of gitosis). I had to chmod a+w to the log and tmp folder before the app shows through Apache. Is there a better way than to chmod every time I deploy to production?

On another thread you said that you used sudo when doing the clone, if so then that is why the permissions are root. You should not need to use sudo, just git clone path/to/file.git provided you have access to the git file and permission to create the folder at the destination.

Colin