Category Archives: mac os/x unix

XAMPP on Mac OSX with Virtual Hosts

XAMPP is an all-in-one LAMP development solution for multiple platforms. I use Linux on my main computer and OSX for my laptop.

I’ve selected XAMPP to provide the LAMP environment on my Mac. It is free, in on-going development and works well.

Because I have several projects in development at once, I need to be able to quickly update my Mac with the current state of a project and then develop and test. Subversion is part of that equation and Komodo IDE is too. Setting up LAMP on Linux is a snap, but installing everything on the Mac, even with MacPorts would be tedious. There are a few pre-packaged solutions, including XAMPP, MAMP and Zend Server. I chose XAMPP after a little research and it has worked well for me.

The Apache virtual server does not come enabled by default, so a little setup is needed.

Folder for virtual websites

Create the folder “www” in your home directory, this example is in Terminal:

cd ~
mkdir www

This is the folder where you will place each of the virtual site directories. You could just as well put this somewhere else, but a “www” directory here makes sense to me.


Add the following to /Applications/XAMPP/etc/httpd.conf

	Options Indexes FollowSymLinks ExecCGI Includes
	AllowOverride All
	Order allow,deny
	Allow from all

In the above you will need to substitute your username for “yourusername”. This simply sets some Apache settings for the folder where your virtual sites will be.

In this same file find:

# Virtual hosts
#Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf

…and un-rem out the Include line. This enables virtual hosting. Yay!


For each website, add a code block to /Applications/XAMPP/etc/extra/http-vhosts.conf

    DocumentRoot "/Users/yourusername/www/"
    ErrorLog "/Users/yourusername/www/"
    CustomLog "/Users/yourusername/www/" common

In the above, just follow the same pattern I’ve shown for this example site. Don’t vary from this unless you want to do some research and testing. You can see I place a “public” folder insite the top directory for a particular virtual site – put your web documents to serve here.

hosts file

Edit your /etc/hosts file to add “” (your version of this) to a line starting with “” like this:

Restart Apache

Using the XAMPP control stop and re-start Apache.


Something like XCOPY on the Mac?

This is an answer to a question about how to recursively copy newer files from one directory to another with a Mac. By “recursively” I mean including sub directories. …Oh, and this is using the Unix shell in Terminal. (Remember, the easy way to get to Terminal is Command-Spacebar to open Spotlight and then type Terminal and open it.

xcopy C:/source X:/destination /e/s/d/y

In Windows, the above command does this and does not prompt when overwriting files.

My first thought was “cp -fuRp * /destination” but there is no -u parameter in OS/X! Egad.

So, then I thought of “rsync” and that seems to do the job:

rsync -aruv * /destination

This example assumes the directory you are copying from is the working directory.

-a Archive mode – retains file settings including dates
-r Recursive – subdirectories
-u Update – only copy newer files
-v Verbose

Remember! Don’t use “*.*” in unix. There are no Windows-style file name extensions.

Yes, it is different from Windows. Yes, it has to be learned to be used. Keep in mind that you had to expend effort to learn DOS/Windows commands and that Unix isn’t going away – what you learn will continue to be useful are a long time.