Getting Ruby on Rails working with Apache

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

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
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

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

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