Steven's Notebook

Look Ma - No Hands!

Apache Virtual Domains and PHP

Back in January I was asked to help build a new site/blog and was happy to do so (they insisted on the colors, don’t shoot me if you don’t like ’em). Frederick also is a video producer, with his vidcasts on the iTunes Music Store, and wanted an easy way to them on the weblog as well. I used a little PHP and some JavaScript to build a dynamic list in his sidebar (see “hollywood if you could”), all he has to do is put his new movie files into the right directory.

The next step, of course, was to replicate this to other servers for other projects of his, and that’s where we ran into a small snag. No matter what we did, the PHP code just didn’t want to run. MOD_PHP was installed, we had the same .htaccess defined, permissions were right – it just didn’t look like Apache server was sending our code to the PHP processor at all. Well, that turned out to be exactly the problem.

The new sites had been created as virtual domains and the web “control panel” that created the virtual domains had added a VirtualHost section to Apache’s httpd.conf file, with ServerName, ServerAlias and DocumentRoot entries, but to have that .htaccess file read and acted upon we also needed a section for our directory as well, with an AllowOverride entry.

<virtualhost>
  ServerName virtualdomain.domain.tld
  ServerAlias www.virtualdomain.domain.tld
  DocumentRoot /var/thevirtualdomain
</virtualhost>
<directory /var/thevirtualdomain>
  AllowOverride FileInfo
</directory>

Thanks to Lance B. for helping us find that.

Steven's Notebook © 2000-2018 Frontier Theme