# Getting Ruby on Rails working with Apache

**URL:** <https://www.ruby-forum.com/t/getting-ruby-on-rails-working-with-apache/79522>\
**Category:** Rails\
**Created:** [December 15, 2006, 11:40pm UTC](https://www.ruby-forum.com/t/getting-ruby-on-rails-working-with-apache/79522 "2006-12-15T23:40:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jackster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jackster](https://www.ruby-forum.com/u/jackster)\
**Post date:** [December 15, 2006, 11:40pm UTC](https://www.ruby-forum.com/t/getting-ruby-on-rails-working-with-apache/79522/1 "2006-12-15T23:40:38Z")

</div>

I just bought space on a virtual server that has Ruby and Ruby on Rails  
installed.  
I ran the script to install the basic “Hello World” code but it  
installed the files in /work/demo which is not in my Apache path. I  
tried to bring up Webbrick which worked but my provider blocks port  
3000 so I can’t access it.

How do I get basic Ruby on Rails working in my /usr/local/apache/htdocs  
directory?

thanks

---

<div class="post-metadata">

**Author:** ![jackster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jackster](https://www.ruby-forum.com/u/jackster)\
**Post date:** [December 16, 2006, 12:28am UTC](https://www.ruby-forum.com/t/getting-ruby-on-rails-working-with-apache/79522/2 "2006-12-16T00:28:46Z")

</div>

On Dec 15, 2006, at 10:39 pm, jackster wrote:

> htdocs  
> directory?

You don’t need rails in your Apache directory - Apache won’t be  
serving the rails app iteslf. You need to set up proxying inside  
Apache to proxy requests to port 80 of your virtual server to port  
3000 (or whatever) locally. This is done with the ProxyPass and  
ProxyPassReverse directives.

Have a look at the docs here: [Module Index - Apache HTTP Server Version 2.2](http://httpd.apache.org/docs/2.2/mod/)  
mod\_proxy.html

It’s actually pretty easy, although that page is a bit daunting. I’m  
sure google will offer a more concise tutorial…

Ashley

---

<div class="post-metadata">

**Author:** ![jackster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jackster](https://www.ruby-forum.com/u/jackster)\
**Post date:** [December 16, 2006, 3:45am UTC](https://www.ruby-forum.com/t/getting-ruby-on-rails-working-with-apache/79522/3 "2006-12-16T03:45:03Z")

</div>

Thanks alot for sending me down the right path Ashley.  
I looked up ProxyPass and ProxyPassReverse, do I need both?

Also, should I simply point Apache to the /work/demo directories that I  
created with the ruby script?

Thanks

john

---

<div class="post-metadata">

**Author:** ![jackster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jackster](https://www.ruby-forum.com/u/jackster)\
**Post date:** [December 16, 2006, 11:57am UTC](https://www.ruby-forum.com/t/getting-ruby-on-rails-working-with-apache/79522/4 "2006-12-16T11:57:30Z")

</div>

On Dec 16, 2006, at 2:42 am, jackster wrote:

> Thanks alot for sending me down the right path Ashley.  
> I looked up ProxyPass and ProxyPassReverse, do I need both?

Yes, or things like redirect will fail - because Apache needs to  
rewrite response headers that come out of the rails server that will  
contain localhost instead of the real hostname of the server. The  
host config will look something like

\<Proxy \*\>  
Order deny,allow  
Allow from all

 # or possibly ProxyPass localhost:3000 ProxyPassReverse localhost:3000 

> Also, should I simply point Apache to the /work/demo directories  
> that I  
> created with the ruby script?

No need unless you want apache to server static content directly.  
I’ve never bothered with that because I’ve never managed anything  
where it’s become an issue. I don’t think it’s hard to do though.  
When you are using proxying, the rails app can be on a different  
physical server - indeed that’s the principle behind horizontal  
scaling, which is achieved in apache using mod\_proxy\_balancer. But  
for simple cases you don’t need to worry about that. (At work, we’ve  
got two apache servers that are load-balanced. Our rails apps run in  
mongrel on the same servers, and each apache proxies to its own local  
mongrels only, so our apache configs would be the same as yours  
despite the extra redundancy)

Ashley
