# Rails + Apache2 problem

**URL:** <https://www.ruby-forum.com/t/rails-apache2-problem/120333>\
**Category:** Rails\
**Created:** [November 15, 2007, 9:42pm UTC](https://www.ruby-forum.com/t/rails-apache2-problem/120333 "2007-11-15T21:42:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![paul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/bbe5ce/32.png) [@paul](https://www.ruby-forum.com/u/paul)\
**Post date:** [November 15, 2007, 9:42pm UTC](https://www.ruby-forum.com/t/rails-apache2-problem/120333/1 "2007-11-15T21:42:57Z")

</div>

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](http://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](http://test.mydomain.com) I get a 403 “You don’t have permission  
to access / on this server.”

What’s wrong?

---

<div class="post-metadata">

**Author:** ![paul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/bbe5ce/32.png) [@paul](https://www.ruby-forum.com/u/paul)\
**Post date:** [November 15, 2007, 10:11pm UTC](https://www.ruby-forum.com/t/rails-apache2-problem/120333/2 "2007-11-15T22:11:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![paul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/bbe5ce/32.png) [@paul](https://www.ruby-forum.com/u/paul)\
**Post date:** [November 16, 2007, 12:36am UTC](https://www.ruby-forum.com/t/rails-apache2-problem/120333/3 "2007-11-16T00:36:23Z")

</div>

Start here: [http://mongrel.rubyforge.org/docs/started.html](http://mongrel.rubyforge.org/docs/started.html)

Then, specific instructions for using Mongrel with Apache are here:  
[http://mongrel.rubyforge.org/docs/apache.html](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](http://duncandavidson.com/archives/155)

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

---

<div class="post-metadata">

**Author:** ![paul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/bbe5ce/32.png) [@paul](https://www.ruby-forum.com/u/paul)\
**Post date:** [November 16, 2007, 1:45am UTC](https://www.ruby-forum.com/t/rails-apache2-problem/120333/4 "2007-11-16T01:45:43Z")

</div>

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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![paul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/bbe5ce/32.png) [@paul](https://www.ruby-forum.com/u/paul)\
**Post date:** [November 15, 2007, 11:07pm UTC](https://www.ruby-forum.com/t/rails-apache2-problem/120333/5 "2007-11-15T23:07:49Z")

</div>

Hi Brian,

Thank you very much for your quick response!

a)  
Well would there be a way to run webrick on [subdomain.mydomain.com](http://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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
