How to Enable PHP5 In Mac OS X Leopard
Friday, October 26 2007
I’ve seen a lot of visitors searching for information on enabling PHP5 in Mac OS X Leopard. It turns out to be quite easy. Leopard ships with Apache 2 and PHP 5 pre-installed. To enable PHP simply:
- Open your favorite text editor and edit
/private/etc/apache2/httpd.conf Uncomment line number 114. It should read
LoadModule php5_module libexec/apache2/libphp5.soOpen System Preferences and go to Sharing
- Stop and then restart Web Sharing
That’s it!
PS - If you want any easy way to setup and manage virtual hosts on your Mac, check out VirtualHostX.

July 4th, 2008 at 1:13 pm
I did a search (since you don't give the full path/location) for httpd.conf and returned nothing - does this mean it isn't installed ( i have leopard)…
July 4th, 2008 at 2:04 pm
I do give the full path to httpd.conf. It's “/private/etc/apache2/httpd.conf”.
July 4th, 2008 at 3:06 pm
Hmm. Well, I can't seem to find a directory on my HD labeled “private” - where is this at starting from Macintosh HD? I even tried typing the above path into terminal and says ” not such directory”. What am I doing wrong?
July 4th, 2008 at 3:10 pm
System directories like /private don't appear in the Finder (normally). You should be able to access them via Terminal without problems. Any path that begins with a single forward-slash “/” means it's starts from your top-most root directory.
July 4th, 2008 at 3:21 pm
OK - I found it, thanx. Crazy.
July 23rd, 2008 at 5:45 pm
Thank you ;)
July 26th, 2008 at 3:56 pm
well I don't have a /private/etc/apache2 directory on my mac. I do have a /etc/httpd/httpd.conf but adding the LoadModule php5_module libexec/apache2/libphp5.so to it doesn't help either, never had this much trouble getting php up and running.
July 26th, 2008 at 4:23 pm
Jabberwocky: The instructions I posted were for Leopard. If you're running Tiger, it's best to use Marc Liyanage's PHP installer here: http://www.entropy.ch/software/macosx/php/
July 28th, 2008 at 4:26 pm
Thank for the link.
August 1st, 2008 at 9:28 am
Those who aren't familiar with the Terminal, can use the Finders “Go To Folder…” command which you can find in the “Go” menu or by using the key combination Shift-Command-G. There, type “/private/etc/apache2″ (wihtout the “).
October 31st, 2008 at 7:43 am
[...] also assume that you have PHP5 ENABLED on your Leopard Machine. It’s quite easy to do and Tyler can help a bunch on this. In short: move the /etc/php.ini.default to /etc/php.ini, and edit /etc/apache2/httpd.conf and [...]
November 13th, 2008 at 6:52 am
I just did this on my super new macbook pro.
in terminal.app write: sudo nano /private/etc/apache2/httpd.conf enter your password press arrow down until you find #LoadModule php5…….. remove the # as you would to in any texteditor press ctrl-o restart apache
done! :)
Thanks for the info.