Drupal on mac OS X using XAMPP with virtual hosts.

Posted in |

The use of virtual hosts allows us to effectively develop using XAMPP in a way that is similar to final deployment. It also allows for multiple installs of Drupal and permits developing for multiple sites using a single Drupal installation.

In this case we are aiming to set up a development virtual host installation with a URL of www.mugginsoft.local

  1. Install XAMPP.
  2. Install Drupal into /Applications/XAMPP/htdocs/drupal6-mugginsoft.
  3. Edit /Applications/XAMPP/etc/httpd.conf and uncomment the following line
    #Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf
  4. Add virtual host container to /Applications/XAMPP/etc/extra/httpd-vhosts.conf
     <VirtualHost *:80>
        ServerAdmin xxxx@mugginsoft.com
        DocumentRoot "/Applications/XAMPP/htdocs/drupal6-mugginsoft"
        ServerName mugginsoft.local
        ServerAlias www.mugginsoft.local
        ErrorLog "logs/mugginsoft.localhost-error_log"
        CustomLog "logs/mugginsoft.localhost-access_log" common
    </VirtualHost>
    
  5. Edit Applications/XAMPP/etc/extra/httpd-xampp.conf to allow .htaccess overrides in directories. This is required to enable the URL rewriting required for clean Drupal URLs. If you find that you can only navigate to site root and every other link fails then it is likely that clean URL rewriting is not occurring correctly. Note that this problem can also occur if you are installing your site from a backup and have omitted to backup .htaccess in the Drupal root folder. Remember, it's this file that actually does the clean URL rewriting.
     Alias /drupal6-mugginsoft "/Applications/XAMPP/htdocs/drupal6-mugginsoft"
        <Directory "/Applications/XAMPP/htdocs/drupal6-mugginsoft">
          AllowOverride All
          Order allow,deny
          Allow from all
        </Directory>
    
  6. Restart XAMPP.
  7. Edit /etc/hosts to map our local URL to the localhost.
    127.0.0.1       www.mugginsoft.local
    Flush the cache with
    dscacheutil -flushcache>
  8. If necessary duplicate /sites/mugginsoft.com as /sites/mugginsoft.local and modify our settings.php as required.

By creating multiple virtual hosts we can can install and develop across a wide range of Drupal installations and versions.

Submitted by Jonathan Mitchell on Sat, 08/01/2009 - 21:50

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
Let us know you are human.
4 + 10 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.