Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm sorry if this is a stupid question, but I can't get Ruby on Rails to work on my Apache server. I'm using Phusion Passenger (mod_rails, mod_rack) for app deployment. Here is my RoR-specific configuration code in my website's Apache configuration file:

Alias /rails /var/www/syyborg.com/ruby/blog/public
<Directory /var/www/syyborg.com/ruby/blog/public>
     Options FollowSymLinks
     AllowOverride None
     Order Allow,Deny
     Allow from All
</Directory>
RailsBaseURI /rails

Again, I really have very little knowledge of this kind of thing; I have never set up a server from scratch before. Anyways, my rails app, as you can see, is located at /var/www/syyborg.com/ruby/blog/. I am trying to access it from http://[my domain, syyborg.com]/rails. However, when I try to load the site, I get a "403 Forbidden" error. Any help would be greatly appreciated, and I can provide further details if they are required. Thanks in advance!

share|improve this question
    
How did you install Ruby, do you have the proper versions? If you installed it manually, I'd install it with RVM instead. This makes ruby and ruby on rails development a LOT simpler and according to your errors it does not seem to be set up properly. –  Jeff Apr 12 '11 at 16:47
    
@Jeff Ok, I'll have to try that. I used the command apt-get install ruby ruby-dev libreadline-ruby libopenssl-ruby ri rdoc irb libhtml-template-perl psmisc -y to install Ruby and its dependencies, then cd /root; wget http://production.cf.rubygems.org/rubygems/rubygems-1.7.2.tgz; tar xzvf rubygems-1.7.2.tgz; cd rubygems-1.7.2; ruby setup.rb to install Ruby Gems, and gem install rails to install RoR. –  Luke Crowe Apr 12 '11 at 17:02

3 Answers 3

If mod_rails is properly installed & loaded, the only configuration you need in apache is to point the document root to the public folder. mod_rails is smart enough to realize where the rest comes from. in apache: the <Directory> statement refers to the physical file location rather than the perceived path. This should also be your public folder for your rails app.

i.e.

<Directory /var/www/syyborg.com/ruby/blog/public>
     Options FollowSymLinks
     AllowOverride None
     Order Allow,Deny
     Allow from All
</Directory>

and your RailsBaseURI should be the path you're looking to use.

i.e.

RailsBaseURI "/rails"

Your alias statement looks fine.

share|improve this answer
    
Thanks! Unfortunately, I got the same error as before... –  Luke Crowe Apr 12 '11 at 17:15
    
did you "reload" apache or "restart" it? Passenger sometimes gets quirky if you don't do a restart. I have this configuration setup in production environments with 0 problems... with only one difference. I also explicitly specify "RailsEnv production" in the <Directory> statement. –  TheCompWiz Apr 12 '11 at 17:33
    
Yes, I did reload apache (through sudo /etc/init.d/apache2), and also tried declaring RailsEnv production. Both returned the same error I've been encountering. –  Luke Crowe Apr 12 '11 at 17:39
    
by restart.... I meant sudo /etc/init.d/apache2 restart ...not reload. Also, check permissions/ownership of the files. It may not hurt to add a PassengerRoot /var/www/syyborg.com/ruby/blog entry either –  TheCompWiz Apr 12 '11 at 17:51
    
I executed sudo etc/init.d/apache2 restart and nothing changed. Then, I chmoded the Rails app folder so that any user could read and write to it. Now, instead of showing the Passenger error, it shows a "403 Forbidden" error. –  Luke Crowe Apr 12 '11 at 18:03

It sounds like mod_rails is not installed. Assuming that you have this:

gem install passenger

and

passenger-install-apache2-module

Try to see if you can start passenger by itself like this:

cd /path/to/your/webapp
passenger start
share|improve this answer

Passenger uses some filesystem magic to find the actual Rails apps. All its actions are based of the DocumentRoot of your virtual host.

Basically, passenger needs two configuration settings set:

  1. It needs to know which URL path should be a rails app. This is done by setting the RailsBaseURI value in your Apache config.
  2. It needs to know where the Rails application is located in the filesystem. Here it uses a rather special approach. Namely a symlink pointing to the public directory of your rails app (not the RAILS_ROOT). This symlink needs to be inside the DOCUMENT_ROOT directory.

So assuming your DocumentRoot is /srv/www, you need to create the following symlink:

ln -s /var/www/syyborg.com/ruby/blog/public /srv/www/rails

Note that it is considered good practice to NOT put your rails app inside the DOCUMENT_ROOT. Also, Passenger does not support the VirtualDocumentRoot module currently.

For more information, refer to the respective section of the Passenger documentation.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.