views:

57

answers:

1

I'm spinning my wheels... Apache is working and serving static html, png, etc. normally. Trying to get Passenger to serve a rails app out of www.mydomain.com/rails/

as it stands when i try to hit my app: www.mydomain.com/rails/myapp/railsclassname I get only an Apache 403 Errors. Nothing in myapp's Production Log.

Apache2 access.log:

"GET /rails/ HTTP/1.1" 403 1085

Apache2 error.log:

[Fri Jun 11 22:44:01 2010] [error] [client 10.0.1.41] File does not exist: /Library/WebServer/wwwroot/rails/railsclassname

i've even tried www.mydomain.com/myapp/classname

Passenger, obviously, isn't routing requests made into my sub-folder rails/ to my rails app. not sure where i've screwed up. the most obvious thing is "Passenger doesn't seem to be running"... instructions I've followed just say to sudo apachectl graceful, which i've done (as well as stopped/started). new to this so go easy on me!

Here's some info that might be helpful. happy to provide more as needed...


As per some instruction @ Passenger site i've created a symlink from /Library/WebServer/myapp/rails -> /Library/WebServer/rails/myapp/public

myhost:myapp joe$ passenger-config --root
/Library/Ruby/Gems/1.8/gems/passenger-2.2.14
myhost:myapp joe$ passenger-status
ERROR: Phusion Passenger doesn't seem to be running.

apollo:myapp joe$ cat /etc/httpd/httpd.conf

...
<removed for brevity>
...
# Copied From Passenger Installer
   LoadModule passenger_module /Library/Ruby/Gems/1.8/gems/passenger-2.2.14/ext/apache2/mod_passenger.so
   PassengerRoot /Library/Ruby/Gems/1.8/gems/passenger-2.2.14
   PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
# End Passenger Installer

  NameVirtualHost *

   <VirtualHost *:80>
      ServerName www.mydomain.com
      DocumentRoot /Library/WebServer/rails/myapp/public    # <-- be sure to point to 'public'!
      RackBaseURI /rails
      <Directory /Library/WebServer/rails/myapp/public>
         AllowOverride all              # <-- relax Apache security settings
         Options -MultiViews            # <-- MultiViews must be turned off
         order allow,deny
         Allow from all
      </Directory>
   </VirtualHost>

This last bit from NameVirtualHost on is pieced together from a number of online material i've found...as i've been desperately trying to find something/anything that'll show Passenger at least has a pulse!?!

A: 

So, you've got

www.mydomain.com
www.mydomain.com/rails

These both point to different websites (lets call them main and rails), the code for each site might be saved on the file system like so:

/Library/WebServer/main/
/Library/WebServer/rails/

We create a symlink from your rails app's public folder to a folder called rails in your main app:

ln -s /Library/WebServer/rails/public /Library/WebServer/main/rails

Then we create a VirtualHost for the main site (not the rails one, and I'm assuming the main site is not rails) and add the rails app as a sub URI, like so:

<VirtualHost *:80>
  ServerName www.mydomain.com
  DocumentRoot /Library/WebServer/main
  <Directory /Library/WebServer/main>
    Allow from all
  </Directory>

  RackBaseURI /rails
  <Directory /Library/WebServer/main/rails>
    Options -MultiViews
  </Directory>
</VirtualHost>

(If you already have a VirtualHost set up for your main website, you can add the RackBaseURI and preceding Directory declaration to that instead).

Now restart apache and you should be able to go to:

www.mydomain.com/rails

and see the "Welcome to Rails" page, or:

www.mydomain.com/rails/controllername

Hope that helps.

Delameko
Thanks! very helpful. and it's working now. kind of. `www.mydomain.com/rails` works but `www.mydomain.com/rails/` does not! Also `www.mydomain.com/rails/controller/new` and `www.mydomain.com/rails/controller` both work BUT `www.mydomain.com/rails/controller/1` and `www.mydomain.com/rails/controller/show/1` do not?!?
Meltemi
It's because /rails/ is handled by Apache's directory handler. You can get around this by disabling mod_autoindex in Apache. RailsAllowModRewrite should be off by default, and this will remove the problem, but some configurations this gets overridden.
Delameko
What errors do you get when accessing controller/1?
Delameko