Friday, July 16, 2010

Enabling PHP on stock Mac OS X 10.6 Snow Leopard

A quick way of enabling the stock installation of PHP on Mac OS X 10.6 "Snow Leopard". You may use either the Terminal or the user interface of the Finder.

1. Go to "/etc/apache2"

2. Use either of the options:

2.a. If using Finder: Give yourself access privileges (read-write access) to file "httpd.conf" and open the file using your favourite text editor

2.b. If using Terminal: Using your favourite text editor (vi, pico etc), using sudo open the "httpd.conf" file.

3. Uncomment (remove the #) in front of line:
LoadModule php5_module libexec/apache2/libphp5.so
4. Add the following lines (preferably at the end of the document so that it is easier to debug later if required):
#IfModule php5_module$
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
In the above, replace # with an "<" and the $ with an ">"

5. Try by running a test php page.

<?php phpinfo(); ?>

In the above, replace # with an "<" and the $ with an ">"

No comments: