Franken-php-rails-apache-stein

Every wondered about the possibility of running a rails app, and a php (or anything else for that matter) site together, on one virtual host, on apache. But why? the hordes screamed … DHH keels over … the PHP community says ahh just put it in CakePHP… and to you it feels just plain *wrong*.

However, there is always that odd need, every now and then, that you have to do it. So here’s how.

It’s really simple, assuming you’re using mongrel cluster and setup a balancer in Apache for it, like so in one of the conf files…

<Proxy balancer://mybalancer.rowanhick.com>
BalancerMember http://localhost:2000
BalancerMember http://localhost:2001
BalancerMember http://localhost:2002
</Proxy>

Then on the paths that you want to mash up with your vhost, it’s as simple as this…

For specific file mapping to an action:

ProxyPass /some_path/some_file balancer://mybalancer.rowanhick.com/mycontroller/myaction
ProxyPassReverse /some_path/some_file balancer://mybalancer.rowanhick.com/mycontroller/myaction
ProxyPreserveHost On

For one path mapping to a controller:

ProxyPass /some_path/ balancer://mybalancer.rowanhick.com/mycontroller/
ProxyPassReverse /some_path/ balancer://mybalancer.rowanhick.com/mycontroller/
ProxyPreserveHost On

Restart and you’re away.

(even if it feels dirty)

No Comments, Comment or Ping

Reply to “Franken-php-rails-apache-stein”

About

Rowan is a Director of Technology for a large marketing services company, specialising in architecting, developing and putting web applications into production - in particular Ruby on Rails based apps. He lives in Toronto, Canada but speaks in a funny accent as he's originally from New Zealand. He's been working in the software and web business for over a decade. This blog covers Web Application development and deployment in the real world, dealing with topics from business fundamentals to Ruby on Rails, Merb, PHP, Flex, MySQL, Apache and more.

Read more ...

 

 

View Rowan Hick's profile on LinkedIn

 

Subscribe to my RSS feed