I spent quite a lot of time pulling my hair out over this one but finally was able to massage cpanel so that our ruby on rails site which uses mod_rails / passenger would ignore a specific directory that we wanted to run a PHP app ( Drupal ) in. You CAN run php by default but you have to go to the script explicitly – i.e. going to /drupal/index.php was ok but /drupal/ threw and error. So the problem was two fold – figuring out how to tell passenger to ignore that entire directory and then how to get this configured in cpanel in the ‘proper’ way.

At first I got bogged down trying to get it to work with some url rewrites in the .htaccess file. It seemed logical but it didn’t work because passenger does it’s thing before .htaccess even kicks in. Besides, the best approach is to bypass passenger completely for that directory – better for optimizing and is really more true to what we were trying to setup.

After digging I discovered the ‘PassengerEnabled’ directive! I know RTFM. Just set PassengerEnabled off for that directory and we’re golden.

Now how to fit it into cpanel but just for this domain? Not as simple as it sounds. Editing the httpd.conf is of course NOT the right solution. Cpanel does expose some parts of the apache configuration in the admin but it’s not vhost specific so again it would affect all sites when I just wanted to change one. RTFM again and you’ll see there are some manual ways to insert things directly into the vhost. You have to manually create a series of directories (the userdata one at the top of the chain is not there by default) and put an override file named anything.conf in the right place.

In my setup i created the file override.conf here:

/usr/local/apache/conf/userdata/std/<vhost account number>/<cpanel user name>/<domain name>/override.conf

And put this in it (/drupal is the folder i want to run php in).

<Location /blog>
PassengerEnabled off
</Location>

And now one more hitch…

Running /scripts/verify_vhost_includes like it says to in the cpanel docs said that my vhost file had an error!!! It said PassengerEnabled was not a valid directive. I ended up just giving it a shot anyways and was pleased to find that it worked just fine! I suspect that cpanel just doesn’t know this directive becuase it is specific to passenger. So you run:

/scripts/ensure_vhost_includes --user=<cpanel user name>

to rebuild the vhosts file for this user and restarts apache and voila!

Whew