Today was a long day indeed. I had to configure the server,I talked about in my last post , to run a ruby on rails app. Apache cannot serve ruby apps out-of-the-box and therefore required add-ons, basically application servers. The role of a application server is to load the Ruby app in its own process space and then communicate with the internet. For Ruby, there is a veriety of options to choose from, but the one preferred by most is Phusion Passenger, the reason being it integrates directly into Apache and Nginx. So, while mod_php module allows apache to hosts PHP application, passenger a.k.a mod_rails allows it to serve ruby app. So, how I went about using passenger?

After I had already hosted my websites, I came across this article which said that xampp was not production ready, intended only for development purpose. Still I thought to give it a try, until I started facing problem while installing passenger. With xampp installed, passenger could not detect the installation of apache2 and therefore when I did passenger-install-apache2-module, it installed apache2 and its development files too. This meant that now I had 2 installation of apache on my server. Having multiple apache installations is not a good idea because:
1) It becomes difficult to know which installation is hosting a particular website
2) The installations have to be modified to listen to different ports

I found that the developers had come up with a way to address such a situation. Please note that the location of the httpd executable and apxs might differ from what is given here. You need to search for it in bin. Also, for those who are inclined on using xampp together with phusion, please note that you need to install xampp development files in addition to the xampp core files. With explicitly stating locations of httpd,apsx,apr-config,apu-config(all occur in the same bin directory), I was able to install phusion without installing apache again. However, even after this, I could not get my rails app to work. With the correct url, I would get the directory listing of public folder of the app, instead of how the app appeared on my development server. I couldn’t get a working solution for this and so, I decided to start frest and replace xampp with the lamp stack.

This article gives a very nice step-by-step procedure for installing lampp. Remember to delete all config files of the previous xampp installtion, else you might face difficulty in lampp installation. With this done, I set about installing phpmyadmin also. Please note that phpmyadmin installed this way installs a slightly older version of php,which is in ubuntu’s apt-get repositories.

Having installed lampp, I followed the procedure to install phusion passenger, step by step. Note that this section comes in handy after the installation to configure apache. When it was all done, I restarted apache and was met by a blue screen that showed me some error, but I was glad finding the Phusion Passenger text on it.

This was not a passenger issue, rather a rails issue. I hadn’t specified the devise secret as well as the production secret key base which is a long hash generated by rake secret. For a initial setting I just specified a random string in production.rb and sure enough the next apache restart brought my app to the internet.

As I see it now, phusion passenger really made my life easy and I thank its developers for this. Did I forget to mention that it is open source? although purchasing it gives you enterprise benefits.

This answer, by one pf passenger’s main contributors is really a good read.