Routing Error with Passenger for Images and stylesheets

You didn't say what server you were using, but you need to point passenger to your *public* directory, not RAILS_ROOT as described here: http://www.modrails.com/documentation/Users%20guide%20Apache.html#_deploying_to_a_virtual_host_8217_s_root

The Apache VirtualHost section they use as an example is:

<VirtualHost *:80>    ServerName www.mycook.com    DocumentRoot /weebapps/mycook/public </VirtualHost>

They have a section on nginx if that's the server you are using.

Hope this helps.

Steve Ross wrote:

You didn't say what server you were using, but you need to point passenger to your *public* directory, not RAILS_ROOT as described here: Phusion Passenger users guide, Apache version

The Apache VirtualHost section they use as an example is:

<VirtualHost *:80>    ServerName www.mycook.com    DocumentRoot /weebapps/mycook/public </VirtualHost>

They have a section on nginx if that's the server you are using.

Hope this helps.

Oh, yeah, thought the config file would make it obvious. It's Apache with Passenger. And I am pointing to the public directory:

Directory "/home/me/public_html/myapp/current/public

John T. wrote:

Oh, yeah, thought the config file would make it obvious. It's Apache with Passenger. And I am pointing to the public directory:

Directory "/home/me/public_html/myapp/current/public

With thanks to Hongli Lai over on the Phusion Passenger Google Group, I got this sorted out. And for completeness and to help others this is what I did.

I set up a new directory under /var/www:

/var/www/myapp

and created a symlink from there to my app's public folder:

ln -s /home/me/public_html/myapp/current/public myapp

and changed my apache vhost file to be:

<VirtualHost *:80>   ServerName myserver.com   DocumentRoot /var/www/myapp   <Directory "/var/www/myapp">     Options FollowSymLinks     AllowOverride None     Order allow,deny     Allow from all   </Directory>   RailsBaseURI /myapp </VirtualHost>

and made sure to include:

config.action_controller.relative_url_root = '/myapp'

in my environment.rb file.

Hongli's description:

/var/www/myapp should be a directory. Inside this directory there should be a 'myapp' symlink. Like this:

/var/www/myapp/ /var/www/myapp/myapp -> /home/me/public_html/myapp/current/public

When you say "RailsBaseURI /something", then Phusion Passenger will look for a filesystem entry "$DOCUMENT_ROOT/something", and this *must* be a symlink to the 'public' directory of your Rails app.

Hope this helps someone else!

jt