Getting PHP Working on Mac OS X

Ruben the Perl Programmer: I resent that remark

I consider myself a more experienced Perl programmer, though I do need PHP to run some of the programs I download. Mac OS X comes bundled with PHP, but it needs to be enabled in Apache before you can run PHP programs on your websever. Dang.

From the always useful

Using the, Start the located in the “/Applications/Utilities/” directory, then change the directory to the “httpd” directory using the following command:

cd /etc/httpd

Next step is to use “root” privileges, start up the text editor named “Pico” and edit the “httpd.conf” file.

Use the following command in the

sudo pico httpd.conf

Type the root password and you are ready to go.

Locate the 4 lines:

#LoadModule php4_module
#AddModule mod_php4.c
#AddType application/x-httpd-php .php
#AddType application/x-httpd-php-source .phps

Use your arrow keys to navigate the document and remove only the pound signs “#”. The best way to navigate is to use the DOWN arrow key and stay to the left Side of the document. To remove the pound sign, hit the right arrow to the right Of the sign and then hit the DELETE key.

Warning: Only remove the pound signs!! Keep the lines of code where they are and do not relocate them!! You have been warned!

The changed lines should look like this:

LoadModule php4_module
AddModule mod_php4.c
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps


This is one of about 5000 posts on Rubénerd. View the home page for the latest, or related posts also tagged with:

If you liked this post, feel free to buy me a coffee, leave me a comment on Twitter, or email me at Thanks :).