Tip of the day - APP_ROOT/config/httpd.conf

08 August, 2008

If there's one thing that's saved me no end of heartache it's including Apache conf settings for a Rails app or Merb/PHP/whatever, in the app's config folder. You get versioning for free. You don't forget your settings. You know where to find it every time. No other process can mess with it (not looking at anyone in particular CPanel...). Just make sure your web app can't mess with it :) i.e. create a file /var/rails/myrails/app/current/config/httpd.conf in which you place your host pointing to your rails app. Then in your apache conf file (normally /etc/httpd/conf/httpd.conf) ensure you include the file above. On my main app config file I try to pop in the top of the file the passenger config settings, as again it's easy to find, then any of the required vhost(s) that the app uses. Nice clean and in one place.

Read More

Franken-php-rails-apache-stein

08 June, 2007

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)

Read More

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License.