This is an update to a previous post on enabling PHP on Leopard.  These instructions will get you ready with Apache setup, PHP enabled and MySQL installed

Mac OS X 10.6 (Leopard) comes with both Apache 2.2.6 and PHP 5.2.4 pre-installed, but they’re not enabled by default.

These instructions involve editing some hidden files.  You could the free text editor TextWrangler (a free, cut-down version of BBEdit available from, which can now install directly from the Mac App Store.   Whichever editor you use, you need to make sure it is setup to edit hidden files.  If you don’t want to worry about file permissions, then you can just make all the changes using the terminal, which the following instructions are based on.


It should already be installed with Snow Leopard but not turned on.  Open the terminal and start Apache

sudo apachectl start

Check that it is working by using your browser and enter:


You should see:

It works!


Start the terminal an open the file:


Find the line:

#LoadModule php5_module libexec/apache2/

Uncomment it (remove the # in front of the line). If you find you can not save the file due to file permissions, then fire up the terminal and enter:

sudo pico /etc/apache2/httpd.conf

Make the change and save the file. Restart Apache

sudo apachectrl restart

Next open System Preferences/Sharing and enable Web sharing. Note there the address for your site, which is a folder “Site” under your user folder. You will then be able to see it that works by entering a URL into your webrowser, using the name you gave your computer original:


Create a single file with the name phpinfo.php with this content:


Save the file to your local Sites folder (/Users/UserName/Sites). Then test using the URL (substitute your computer name and user name)


You will get a page showing all the settings for PHP with a heading something like, followed by all the PHP settings.

So where is the php.ini file?  There is not any, but you can add one to /etc by copying

/etc/php.ini.default to /etc/php.ini

Use the terminal and enter

sudo cp /etc/php.ini.default /etc/php.ini

Make it writable

sudo chmod 666 php.ini

In the php.ini file find the line

;date.timezone =

Uncomment it and insert your time zone (
Restart Apache

sudo apachectl restart


Download and install the latest MySQL version from With my new Mac Book Pro (early 2011) I installed the x86_64 version for Intel. Since Oracle has taken over MySQL it is a bit harder to find since you are presented with commercial offerings. Look for the MySQL Community Edition.

Test it is working in the terminal


Edit the phi.ini file

vimo /etc/php.ini

Replace the three occurences of /var/mysql/mysql.sock by using /tmp/mysql.sock

mysql.default_socket = /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock

Finally restart Apache

sudo apachectl restart

Open System Preferences and click on the MySQL preferance pane (which was installed above).  From here you can not start and stop MySQL, and enable it to start automatically when your system starts.

That’s it!