Setting up PHP on Mac OSX 10.6 (Snow Leopard)
by Simon. Average Reading Time: about a minute.
Since Apple launched Mac OS X 10.5 (Leopard), PHP has been installed by default, albeit disabled. Here is a quick run through of what you need to do to get it up and running:
- Enable the PHP5 module in Apache:
LoadModule php5_module libexec/apache2/libphp5.so
This will normally involve simply removing the hash symbol (#) at the beginning of the line.
- Restart Apache via the command line:
sudo apachectl restart -t
The
-tis used to run a syntax check on the Apache file, to ensure you haven’t broken anything. - Locate the
php.ini.defaultfile in the/etc/directory and rename it to simplyphp.iniby running the following commands:cd /etc sudo cp php.ini.default php.ini sudo chmod 666 php.ini
- Create a file in the web server’s document root, in this case an
index.phpfile, with the following text included:<?php phpinfo() ?>
When you browse to that file, it will display information regarding your PHP installation. (Be sure to remove this after use and certainly don’t include it in a production environment.)
That is all you need to do. Easy huh?
As a point to note, if you need to make changes to either the http.conf file or php.ini, you will need administrative access and will need to restart the Apache server for the chances to take effect.
