Setting up a local web server on OS X Snow Leopard 10.6
Basic Web Server
MAMP is great. It’s an easy way to host your PHP/MySQL site locally for testing and development. But, if you want to take advantage of Snow Leopard’s built in web server capabilities, OS X makes it easy. Go into System Preferences > Sharing, and check the “Web Sharing” box.
That’s it. You can now setup an HTML-only website locally. Where do you put the files? The default folder is /Library/WebServer/Documents/. While we’re at it, let’s setup PHP and MySQL to work locally, as well.
Test it. http://localhost. No need for a port as it will use apache’s default port 80.
PHP and MySQL will now need to be setup for a full functioning local host.
Setting up PHP
Open up Terminal (Applications->Utilities->Terminal) and type:
sudo nano /etc/apache2/httpd.conf

Go to this line
#LoadModule php5_module libexec/apache2/libphp5.so
and uncomment the line by removing the hash character
LoadModule php5_module libexec/apache2/libphp5.so
After saving the file (Control+O) and exiting (Control+X). Restart Apache.
sudo apachectl restart
Configuring PHP
cd /etc
sudo cp php.ini.default php.ini
sudo chmod 666 php.ini
sudo nano php.ini
Find this line and remove the semi-colon
;date.timezone =
and add your own timezone. A list of timezones can be found here (http://php.net/manual/en/timezones.php)
date.timezone = America/Halifax
You’re halfway there. PHP 5 is now running on your local server.
Setting up MySQL
Download the MySQL package for Mac OS X.5 (32 or 64 bits depending on your machine)
Install everything in the package in this order:
- mysql
- the startup item
- the preference pane.
Now, open /etc/php.ini, find these three lines
pdo_mysql.default_socket=/var/mysql/mysql.sock
mysql.default_socket = /var/mysql/mysql.sock
mysqli.default_socket = /var/mysql/mysql.sock
and replace /var/mysql/ with /tmp/
pdo_mysql.default_socket=/tmp/mysql.sock
mysql.default_socket = /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock
After installed, you can start MySQL in the system preferences. To access your database from the Terminal
/usr/local/mysql/bin/mysql -u root

Change your Home Directory
Want your local server’s files to be located somewhere other than the default /Library/WebServer/Documents/? Open /etc/apache2/httpd.conf, and change the next two lines to reflect your new home directory.
DocumentRoot "/Library/WebServer/Documents"
...
<Directory "/Library/WebServer/Documents">
Drupal Problems?
If you’re getting errors during Drupal installation try linking the MySQL sock file like below
cd /
sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
Drupal’s Clean Urls
Having problems enabling Clean Urls? Find all instances of the following line in /etc/apache2/httpd.conf
AllowOverride None
and change None to All…
AllowOverride All
I’m a frontend designer/web designer/graphic designer/regular guy with an insane curiosity for web design, typography, and the art of visual communications. I love to write, and do so in the
Nice and to the point of the matter!
Awesome tutorial. I was using MAMP and it just doesn’t work how I’d like it to. Now my iMac feels even more hawt.