Rails + Apache2 problem

Hello,

I’m quite a noob, after days of work and suffer I managed to deploy my
rails app to my server with capistrano 2.

I don’t use mongrel or lighttpd, webrick is strong enough for my small
projects ;]

my app is in /home/paul/rails/Test/current/

so I created this apache2 virtual host in my httpd.conf:

<VirtualHost *:80>
ServerName test.mydomain.com
DocumentRoot /home/paul/rails/Test/current/public/
ErrorLog /home/paul/rails/Test/shared/log/server.log

<Directory /home/paul/rails/Test/current/public/>
Options ExecCGI FollowSymLinks
AddHandler cgi-script .cgi
AllowOverride all
Order allow, deny
Allow from alll

my script/spin file looks like this:
/home/paul/rails/Test/current/script/process/spawner fcgi -p 80 -i 3 -
r 5

When I access test.mydomain.com I get a 403 “You don’t have permission
to access / on this server.”

What’s wrong?

That doesn’t look correct. Think about it: Webrick is a web server.
Apache is a web server. Rails apps are a collection of Ruby scripts that
(so far) Apache doesn’t understand, but Webrick does. So, you have a
couple choices:

  • for simple webserving, you don’t need both. Webrick can do everything
    (but not necessarily well). So if Webrick is OK for your load, you don’t
    need Apache at all.

  • if you want to use Apache (say, for serving static files), it can’t
    point to the Rails app directly. Remember, Apache doesn’t understand
    Ruby files. So you need to tell Apache to send the request to Webrick.
    However, this usually means setting your httpd.conf file up to tell
    Apache to send some (most) requests to Webrick, but handle requests for
    static files itself.

I use Mongrel, which is pretty much a seamless switch from Webrick.
Mongrel’s site shows you how to deal with all these issues.

Start here: http://mongrel.rubyforge.org/docs/started.html

Then, specific instructions for using Mongrel with Apache are here:
http://mongrel.rubyforge.org/docs/apache.html

Look at this, and you will see that you are using Apache for virtual
hosting, but more specifically, the virtual host you define will pass
all requests to Mongrel on the port you designate.

I neglected to mention that fcgi has fallen out of favor for Rails. See
http://duncandavidson.com/archives/155

But your milage may vary. I’ve been happy with apache2/mongrel.

Yes, this seems to be the best solution!

Can’t thank you enough for your consultation!

Wish you all best,
Paul

On Nov 16, 12:36 am, Brian A. [email protected]

Hi Brian,

Thank you very much for your quick response!

a)
Well would there be a way to run webrick on subdomain.mydomain.com for
example? how could I achieve this?
Thought the only way to do this is with apache’s virtual hosts (in my
case).

b)
Where else should it point to? Can you tell me more (or give me
keywords/resources) about this configuration?

Thank you. I think I will also try to deal with mongrel from now on!

On Nov 15, 10:11 pm, Brian A. [email protected]