Enable PHP 5.3.0 on Mac OS X Snow Leopard

3 Dec

Most Mac users will know that with just a few clicks they can host websites across their home network and with a bit of extra configuration the Internet too. This is great if all you want is to serve up some simple static pages but when it comes to PHP all you will see is a HTML page with PHP tags.

However PHP 5.3.0 comes pre-installed with Snow Leopard. It’s simply not enabled by default. Enabling it to serve PHP pages is a very simple task just follow the steps below and you’ll be serving PHP pages from your Mac in a few minutes!

Step one
You need to open up the terminal application, located within your applications folder inside a subdirectory called utilities, and issue the following command. You will be asked to confirm your user account password.

sudo nano /etc/apache2/httpd.conf

Step Two
Locate the line containing php5_module that will look like this one below:

#LoadModule php5_module        libexec/apache2/libphp5.so

Remove the hash from the line so that it looks like the following:

LoadModule php5_module        libexec/apache2/libphp5.so

Step Three
Locate the line beginning with DirectoryIndex that will look like this one below:

DirectoryIndex index.html

Add index.php to the end of the line so that it looks like this:

DirectoryIndex index.html index.php

Step Four
Exit the text editor and save the file by holding Ctrl and tapping the X key. Tap the Y key to confirm saving and hit the enter key to keep the same filename.

Step Five
Open up System Preferences and choose the Sharing option. Now disable and re-enable Web Sharing.

No comments yet

Leave a Reply