Ruby application on Apache-PHP environment with Phusion Passenger

Switching to Ruby from PHP wasn’t as hard as deploying rails/sinatra app on existing Apache-PHP environment. It should’ve been fairly easy as I choose to do it with Phusion Passenger instead of using Proxy to the rails/sinatra app. But who knew things can get really ugly if I hadn’t tested locally.

Problem Ughhh @#$@%@:

Actually I deployed a rails/sinatra app in production first then was trying to configure in my localhost but then figured out when passenger module is loaded DirectoryIndex index.php isn’t working, meaning index.php of any web application wasn’t recognized by apache by default anymore as before you have to type it in the browser. Digging deeper found out mod_dir is not compatible with phusion passenger offering no fix yet. You might want to check with conflicting apache module with phusion passenger before even trying to install passenger in your existing apache-php environment.

Avoid Catastrophe:

The reason why I did not notice it in my production environment at first because of cache. Once I tried to deploy in my local machine things aren’t working as it was in production. I had to type in index.php to gain access. Checked AddHandler, AddType, DirectoryIndex index.php everything in place and nothing seems to work until I found the conflicting apache modules.

Solution:

There’s a workaround provided by the Passenger team i.e. using PassengerEnabled off. After Passenger module is loaded you can turn it off so that mod_dir can do it’s job setting correct DirectoryIndex, and then enable it where Phusion Passenger is required, preferable inside rails/sinatra app  <Directory> block. If you put it outside it may globally configure which will again make mod_dir not to work. Only when an agent is requesting for the rails/sinatra app it gets turned on for that Directory block and there’s no conflict anymore. A good example is provided at Phusion Passenger Guide. This setting can be done otherway around depending on the number of rails/sinatra and php application you have running in your environment.

Still waiting for something to go wrong just hoping it happens in my local machine ealier.

Local Environment:

Mac OS X Lion 10.7.2 , built in apache2, php5.3.6., rvm 1.10.0, ruby 1.9.2, passenger 3.0.11

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: