Rails & Subdirectories
I spent part of this morning fighting with Rails, trying to get a quick app I wrote hosted below an existing app. It should have been simple, but getting the various pieces cooperating took longer than it should have. The solution is to use the --prefix argument to mongrel_rails. Here's how I got it going:
Scenario:
RailsApp1 hosted as mysite.com/
RailsApp2 hosted as mysite.com/myapp2
Both apps served via Apache 2.0 + mongrel + pen on Debian Sarge
Scripts:
/etc/init.d/mongrel (customized from Debian's skeleton)
/etc/mongrel/sites-enabled/myapp1
/etc/mongrel/sites-enabled/myapp2
No need to modify the rails app itself. Some messages I found suggested various mixes of modifying .htaccess and/or the relevant environment.rb files, but that didn't work for me.
Apache Config:
/etc/apache2/sites-enabled/vhost-mysite.conf:
<pre><br /><VirtualHost *:80><br /><br />ServerName mysite.com<br />DocumentRoot /srv/www/myapp1<br />Alias /myapp2 /srv/www/myapp2<br /><br />RewriteEngine On<br /><br />RewriteCond %{REQUEST_URI} ^/myapp2 [NC]<br />RewriteRule ^/.* <a href="http://localhost:8850/" title="http://localhost:8850%">http://localhost:8850%</a>{REQUEST_URI} [P,QSA]<br /><br />RewriteRule .* <a href="http://localhost:8800/" title="http://localhost:8800%">http://localhost:8800%</a>{REQUEST_URI} [P,QSA]<br /><br /></VirtualHost>

Comments
Post new comment