# \[somewhat OT\] Apache config for Rails + ColdFusion + PHP

**URL:** <https://www.ruby-forum.com/t/somewhat-ot-apache-config-for-rails-coldfusion-php/100188>\
**Category:** Rails\
**Created:** [July 27, 2006, 5:58pm UTC](https://www.ruby-forum.com/t/somewhat-ot-apache-config-for-rails-coldfusion-php/100188 "2006-07-27T17:58:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [July 27, 2006, 5:58pm UTC](https://www.ruby-forum.com/t/somewhat-ot-apache-config-for-rails-coldfusion-php/100188/1 "2006-07-27T17:58:49Z")

</div>

Our group has several web apps developed in ColdFusion, PHP, and Rails.  
The  
ColdFusion and PHP apps are on an older server, and the Rails apps on a  
new  
server. Ideally, we’d like them all to share the same server.

Our current setup for the Rails server is Apache2.2 with  
mod\_proxy\_balancer  
and mongrel\_cluster. We’d like to have specific directories be  
processed  
and served by Apache instead of being handed off to mongrel\_cluster.  
For  
example, let’s say we have 3 applications:

1. our main website done in Rails located at the domain root
2. a ColdFusion app located at /cf\_app/
3. a PHP app located at /php\_app/.

We’d like the ColdFusion and PHP apps to be served by Apache. Anything  
not  
in those two directories should be passed off to mongrel\_cluster for  
processing.

Any ideas on how to handle the Apache config for such a setup?

Thanks,  
Chris

---

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [July 27, 2006, 7:49pm UTC](https://www.ruby-forum.com/t/somewhat-ot-apache-config-for-rails-coldfusion-php/100188/2 "2006-07-27T19:49:45Z")

</div>

> 1. a ColdFusion app located at /cf\_app/
> 2. a PHP app located at /php\_app/.
> 
> We’d like the ColdFusion and PHP apps to be served by Apache. Anything not  
> in those two directories should be passed off to mongrel\_cluster for  
> processing.
> 
> Any ideas on how to handle the Apache config for such a setup?

We don’t have cold fusion and our PHP isn’t as nicely isolated as that,  
but this works for us:

\<Proxy balancer://mongrel\_cluster\>  
BalancerMember [http://127.0.0.1:8805](http://127.0.0.1:8805)

RewriteEngine On

RewriteCond %{DOCUMENT\_ROOT}/%{REQUEST\_FILENAME} -d  
RewriteRule ^(.+[^/])$ $1/ [R]

RewriteCond %{DOCUMENT\_ROOT}/%{REQUEST\_FILENAME} .php  
RewriteRule ^(.\*)$ $1 [QSA,L]

RewriteCond %{DOCUMENT\_ROOT}/%{REQUEST\_FILENAME} !-f  
RewriteCond %{DOCUMENT\_ROOT}/%{REQUEST\_FILENAME}/index.html -f  
RewriteRule ^(.\*)$ $1/index.html [QSA,L]

RewriteCond %{DOCUMENT\_ROOT}/%{REQUEST\_FILENAME} !-f  
RewriteCond %{DOCUMENT\_ROOT}/%{REQUEST\_FILENAME}/index.php -f  
RewriteRule ^(.\*)$ $1/index.php [QSA,L]

RewriteCond %{DOCUMENT\_ROOT}/%{REQUEST\_FILENAME} -d  
RewriteRule ^(.\*)[^/]$ $1/ [QSA,L]

RewriteCond %{DOCUMENT\_ROOT}/%{REQUEST\_FILENAME} !-f  
RewriteRule ^/(.\*)$ balancer://mongrel\_cluster%{REQUEST\_URI}  
[P,QSA,L]

---

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [July 27, 2006, 8:09pm UTC](https://www.ruby-forum.com/t/somewhat-ot-apache-config-for-rails-coldfusion-php/100188/3 "2006-07-27T20:09:36Z")

</div>

an easier way would be to have aliases for php and coldfusion apps and  
have the default location serverd be redirected to the mongrel  
cluster. I am in the middle of setting something like that up now.  
Only without the coldfusion.

On 7/27/06, Philip H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 1. a ColdFusion app located at /cf\_app/
> 
> RewriteRule ^(._)$ $1 [QSA,L]  
> RewriteRule ^(._)[^/]$ $1/ [QSA,L]
> 
> RewriteCond %{DOCUMENT\_ROOT}/%{REQUEST\_FILENAME} !-f  
> RewriteRule ^/(.\*)$ balancer://mongrel\_cluster%{REQUEST\_URI} [P,QSA,L]
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
Elliott C.  
removed\_email\_address@domain.invalid  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [July 27, 2006, 8:31pm UTC](https://www.ruby-forum.com/t/somewhat-ot-apache-config-for-rails-coldfusion-php/100188/4 "2006-07-27T20:31:50Z")

</div>

Here is what I am working on right now:  
\<Proxy balancer://mycluster\>  
BalancerMember [http://192.168.0.1:3000](http://192.168.0.1:3000)  
BalancerMember [http://192.168.0.1:3001](http://192.168.0.1:3001)  
BalancerMember [http://192.168.0.11:3000](http://192.168.0.11:3000) loadfactor=2  
BalancerMember [http://192.168.0.11:3001](http://192.168.0.11:3001) loadfactor=2

\<Location /balancer-manager\>  
SetHandler balancer-manager

\<Directory "/var/www/someplace\>  
Options Indexes MultiViews  
AllowOverride None  
Order allow,deny  
Allow from all

Alias /someplace /var/www/someplace

\<VirtualHost \*:80\>  
ServerAdmin admin@localhost  
ServerName [www.site.com](http://www.site.com)  
ServerAlias [site.com](http://site.com)  
ProxyPass / balancer://mycluster/  
ProxyPassReverse / balancer://mycluster/

Most of my config came from  
[http://blog.innerewut.de/articles/2006/04/21/scaling-rails-with-apache-2-2-mod\_proxy\_balancer-and-mongrel](http://blog.innerewut.de/articles/2006/04/21/scaling-rails-with-apache-2-2-mod_proxy_balancer-and-mongrel)  
I haven’t tested it yet, but it should be close.

On 7/27/06, Elliott C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > Our current setup for the Rails server is Apache2.2 with mod\_proxy\_balancer  
> > > processing.  
> > > RewriteEngine On
> > 
> > * * *

–  
Elliott C.  
removed\_email\_address@domain.invalid  
removed\_email\_address@domain.invalid
