Mac OS X comes with everything a web developer needs. Php, Perl, Ruby, Apache. But they are not activated by default to get your Apache to play nice with default PHP install of OS X. Follow these steps.
Open file called “httpd.conf” which is located under “/private/etc/apache2/” with your favourite editor.
Or, open up a terminal and type,
sudo vim /private/etc/apache2/httpd.conf
Move to line “around 114″ at the end of LoadModule section it should print
#LoadModule php5_module libexec/apache2/libphp5.so
Remove the # symbol to uncomment that line.
LoadModule php5_module libexec/apache2/libphp5.so
Now apache knows about your php module. Go to you System Preferences then sharing and turn on web sharing. To test your installation create a file called hello.php with the following code snippet and place it in /Sites/
<?php Print "Hello, World!"; ?>
If everything went fine going to http://127.0.0.1/hello.php in your browser should print Hello, World!.