HOW-TO: Setup XAMPP to use VirtualDocumentRoot in Mac OS X

I had a lot of trouble upgrading my XAMPP to run the latest PHP. So much so, that I decided to document what I did.

First off, I downloaded the Mac version of XAMPP available from Apache Friends. I probably could use OS X’s built-in Apache server, but XAMPP is portable and in order to keep things consistent from platform to platform I tend to like it better. Make sure you disable Apache by unchecking the “Web Sharing” option of the “Sharing” system preference pane.

If you browse to http://localhost you should see a XAMPP splash page. Success! Next, go back to the XAMPP website and download the devel package, this will install and tweak the settings of the basic install to give you better development tools.

Now some configuration. Other than the usual ramping up the memory and defining the available resources you will need to setup at least one Vritual Host to use Virtual Document Root

XAMPP will serve pages from /Applications/xampp/xamppfiles/htdocs. I keep my websites on a special folder located at /workspace (often times it's just a symlink to another folder somewhere) so we will need to make some adjustments. The idea here is that I can create folders under /workspace like /workspace/rob and be able to get to them via http://rob without having to edit the vhosts file.

In order to keep things clean I created a new file called /Applications/xampp/xamppfiles/etc/extra/httpd-dynamic-vhosts.conf with the following:

$ sudo vim /Applications/xampp/xamppfiles/etc/extra/httpd-dynamic-vhosts.conf

<VirtualHost *:80>
    UseCanonicalName Off
    VirtualDocumentRoot /workspace/%0
    <Directory "/workspace">
        Options Indexes FollowSymLinks ExecCGI Includes
        AllowOverride AuthConfig
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
 
Notice VirtualDocumentRoot and %0 are ONLY available if you load mod_vhost_alias.so.

Next, I included the above .conf file, by adding the following line to the bottom of /Applications/xampp/xamppfiles/etc/httpd.conf:

$ sudo vim /Applications/xampp/xamppfiles/etc/httpd.conf

Include /Applications/xampp/etc/extra/httpd-dynamic-vhosts.conf

Now let's restart Apache and try to load http://rob. Voilá, success!

Rob Montero

Rob Montero, Drupal Association Individual Member

Roberto Montero Ortiz is an individual member of the Drupal Association, which fosters and supports the Drupal software project, the community and its growth. He also has an active role in the Drupal Community in Costa Rica and regularly contributes to Drupal Camps held in Latin America.

Rob Montero, Acquia Certified Developer 2014   Rob Montero, Certified Developer Back End Specialist 2015Rob Montero, Acquia Certified Developer Front End Specialist

Rob is also an Acquia Certified Developer, awarded with the Grand Masters title after completing his third certification within a year. 

Zend also certifies Rob's knowledge of PHP OOP skills, but at this point this block is getting a bit presumptious. Suffice it to say, Rob is competitive and competent. He's also a nice guy all around.

Drupal Latin America

Rob Montero is a proud sponsor and mentor of young Drupal talent of the Costa Rican Drupal Users Group and entrepreneur at Drupal Latin America

CHECK THEM OUT

Get in touch

  • Rob Montero
    Ave Popocatepetl 435 B 504
    Sta Cruz Atoyac, Benito Juarez
    Ciudad de México, 03310 
  • (858) 952 0762
  • roberto@montero-ortiz.com
Signup to our newsletter:
Error | Roberto Montero

Error

The website encountered an unexpected error. Please try again later.