Hybrid website? php and rails

i am writing a new app in rails that i need to run on an existing
domain…

the problem is, there are a few subdirectories on that domain that run a
few old (but necessary) php scripts and a few other things that still
need to be accessible…

is it possible to set up apache so that i can run my rails app using
mod-proxy, but still retain access to the old directories in
~/public_html ?

the only thing i would do is make sure that there is no directory name
overlap in the system…

for example… i couldn’t have /scripts in both apps… which is fine…

i would appreciate any help in getting this set up…

thanks!

I am currently working on porting an old PHP application to Rails.
Except it was decided not to do it all in one fell swoop but over
time, so I have to get the old PHP app and the new Rails app to play
together.

In short, yes, it is quite possible but you gotta know how to use
mod_rewrite and other apache config bits. In my case though, I’m using
litespeed, so it’s a different setup.

The way I have it setup is basically having the PHP app sitting there
and anything that falls through be handled by Rails. It wasn’t that
hard to setup. What was harder was (somewhat) harder was getting
sessions to work together and other things like that.

Hope it helps,
-carl

Sergio R. wrote:

the only thing i would do is make sure that there is no directory name
overlap in the system…

for example… i couldn’t have /scripts in both apps… which is fine…

i would appreciate any help in getting this set up…

thanks!

Read more about mod_rewrite in Apache.
This solve your problem.


Davis [email protected]
Impact Media

C: +55 45 9928 0815
B: http://impactmedia.com.br/blog/

Read more about mod_rewrite in Apache.
This solve your problem.

thanks, guys…

i will check this out…

i am writing a new app in rails that i need to run on an existing
domain…

the problem is, there are a few subdirectories on that domain that run a
few old (but necessary) php scripts and a few other things that still
need to be accessible…

is it possible to set up apache so that i can run my rails app using
mod-proxy, but still retain access to the old directories in
~/public_html ?

Yes.

the only thing i would do is make sure that there is no directory name
overlap in the system…

for example… i couldn’t have /scripts in both apps… which is fine…

i would appreciate any help in getting this set up…

This is what we use and it works fine. (apache2/mongrel)

<VirtualHost *:80>

ServerName myserver.com
DocumentRoot /path/to/my/app/public

<Directory "/path/to/my/app/public">
  Options FollowSymLinks
  AllowOverride None
  Order allow,deny
  Allow from all
</Directory>

<Proxy balancer://mongrel_cluster>
  BalancerMember http://127.0.0.1:8805
</Proxy>

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]

AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml

BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html

php_value include_path /path/to/my/app/php:/usr/local/lib/php:.
php_value auto_prepend_file /path/to/my/app/php/auto_prepend.php

# this not only blocks access to .svn directories, but makes it 

appear
# as though they aren’t even there, not just that they are forbidden
<DirectoryMatch “^/.*/.svn/”>
ErrorDocument 403 /404.html
Order allow,deny
Deny from all
Satisfy All