how to run a php app, like wordpress, next to a rails app on ec2onrails

11 views
Skip to first unread message

broken

unread,
Dec 10, 2009, 4:08:29 AM12/10/09
to ec2-on-rails-discuss
Hey everyone,

I'm trying to run wordpress along with a rails app on an ec2onrails
instance. The rails app is working (yes!). The setup I've been using
took a few lines of apache config on my local passenger setup, but
alas I haven't been so lucky getting it working on ec2onrails.

So far I've got PHP installed by adding 'php5' to this line in the
deploy.rb:

:packages => ["logwatch", "imagemagick", "php5"],

I've added these lines so I can add some apache config:

:server_config_files_root => "config/server_config",
:services_to_restart => %w(apache2),

and I've placed a 'app.custom' file in 'config/server_config/etc/
apache2/site-available'. When I 'cap ec2onrails_setup' the
'app.custom' file copies over like a charm. Inside the 'app.custom'
is:

Alias /blog /mnt/wordpress
<Directory "/mnt/wordpress">
AllowOverride All
Options FollowSymLinks
Order allow,deny
Allow from all
</Directory>

But every request to 'http://mysite.com/blog' goes to the rail app
'page not found' page. What I believe I'm stuck on are these rewrite
rules sending everything over to the balancer, found in '/etc/apache2/
sites-available/app.common':

RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L]

I need to figure out a way to punch a hole in that rule so that
traffic to '/blog' goes to my Alias directive rather than redirecting
away to the mongrel cluster. If someone knows how to do that off the
top of their head I'd be much obliged if they could give me a
pointer...if not I shall embark on decoding the meaning of those lines
and let y'all know once I've figure it out...

broken

unread,
Dec 11, 2009, 12:51:38 PM12/11/09
to ec2-on-rails-discuss
I figured it out. I added a line to app.common like so:

# Redirect all non-static requests to cluster
#### next line added to poke a hole for blogx
RewriteCond %{REQUEST_URI} !^/blogx(.*)$
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L]

I also added one here, otherwise the directory index wouldn't resolve
and hitting /blog/ or /blog/something/ would result in an error rather
than showing the index.php:

# Rewrite to check for Rails cached page
#### next line added to poke a hole for blogx
RewriteCond %{REQUEST_URI} !^/blogx(.*)$
RewriteRule ^([^.]+)$ $1.html [QSA] ####

Viola!
Reply all
Reply to author
Forward
0 new messages