Wednesday 31 August 2011

How can I serve ruby and php on same apache machine?

Hi, I was caught up in between issues of deploying a ruby app behind an apache server, while allowing others like PHP to continue running normally. Here is the set of steps that worked for me.

-Ensure Phusion Passenger is installed and configured in apache.If you don't have them, run these two commands to install passenger and configure it automatically
             $ sudo gem install passenger
             $ sudo passenger-install-apache2-module

-make a directory /var/www/mywebsites/
-throw the ruby app into /var/www/mywebsites/
eg scp -r cce /var/www/mywebsites/
-create a symbolic link to /var/www/mywebsites/cce/public
e.g ln -s  /var/www/mywebsites/cce/public /var/www/cce

-Configure vHosts as follows

<VirtualHost *:80>
  # Normal virtual host info
  ServerName localhost
  #ServerAlias *.seanbehan.com
  DocumentRoot /var/www/
  <Directory /var/www>
         Options FollowSymLinks
        AllowOverride None
        Order deny,allow
        allow from all
        Satisfy all
  </Directory>
  RailsBaseURI /cce
  <Directory /var/www/cce>
        Options Indexes Multiviews FollowSymLinks
        AllowOverride all
        Order allow,deny
        Allow from all
  </Directory>          
  ErrorLog /var/log/apache2/error.log
  LogLevel warn
  CustomLog /var/log/apache2/access.log combined
</VirtualHost>

-------------------------------
We are done. Run http://localhost/cce and the app loads seamlessly.
Have fun!

Simon.