Enabling PHP in Leopard
If you’re like me and really hate that process of searching, downloading and compiling to install programs, you will definitely appreciate that PHP5 is included in Mac OS 10.5. Unfortunately, it is not enabled by default to work with the built-in web server. Fixing this can, however, be done in about five minutes.
Fire up a Terminal window (Applications/Utilities/Terminal.app).
Note: This will only work if Leopard was installed as a “fresh OS” (i.e. not an upgrade installation).
In your Terminal window, type:
cd /Volumes/Macintosh\ HD/private/etc/apache2/
This command will put you in the Apace2 directory. In this directory, we will make changes to httpd.conf, the Apache2 configuration file. Before we start, it is good practice to make a backup copy of the original file, just in case you need to revert to it in the future.
Make a copy of original httpd.conf file:
sudo cp httpd.conf httpd.conf.default
The command sudo uses Administrator rights to make a copy of this configuration file. Provide the Administrator password when it is requested.
Next, edit the configuration file with the built-in text editor, Vi. Again, provide the Administrator password when requested:
sudo vi httpd.conf
Search the document for the following line.
Type: /
Search for: #LoadModule php5_module
With the cursor on the hash symbol (#), type “i” to enter Insert Mode. Move the cursor one character to the right and Delete the hash symbol.
Press Esc to exit Insert Mode.
Press Shift + ‘:’ to enter a command.
Type in wq! to save and exit the file.
You will be returned to the command line. The next step is to edit the PHP configuration file, php.ini.default.
Change your directory:
cd /private/etc/
Make a copy of the php.ini.default template:
sudo cp php.ini.default php.ini
Use Vi to edit the file:
sudo vi php.ini
Like before, use Vi’s search feature to find:
error_reporting = E_ALL & ~E_NOTICE
There are a few lines that contain the above string. Find the line that does NOT begin with a semi-colon (;).
Change this line to read:
error_reporting = E_ALL
Press Esc to exit Insert Mode.
Press Shift + ‘:’ to enter a command.
Type in wq! to save and exit the file.
Now, navigate to Sharing in System Preferences and start/restart Web Sharing.
Create a PHP file in your Site directory and verify it is displayed correctly.You are all done! Good luck and happy coding!






Cool post!