Click On Tyler Hall

Originally from Nashville, I'm an engineer working for Yahoo! in Sunnyvale and paying my way with PHP and Cocoa.

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.so

  • Open 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.


Reader Comments


  1. zada Says:

    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)…

  2. Tyler Says:

    I do give the full path to httpd.conf. It's “/private/etc/apache2/httpd.conf”.

  3. zada Says:

    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?

  4. Tyler Says:

    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.

  5. zada Says:

    OK - I found it, thanx. Crazy.

  6. X-Phreedom Says:

    Thank you ;)

  7. jabberwocky Says:

    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.

  8. Tyler Says:

    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/

  9. jabberwocky Says:

    Thank for the link.

  10. mise Says:

    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 “).

  11. Petar Smilajkov - Peconi » Blog » Enabling GD for PHP on OSX Leopard (10.5.x) Says:

    [...] 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 [...]

  12. Simme Says:

    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.


Leave a Reply