To clarify Neoryder's post, edit /etc/apache2/httpd.conf
, find the line:
#LoadModule php5_module libexec/apache2/libphp5.so
and remove the hash sign from the beginning to enable PHP in your web server. You have to go to your Sharing preference pane and uncheck and recheck Web sharing for the change to take effect.
I'll mention one more thing that caught me out moving from Linux to OS X...
Most people want to serve PHP files from their own Sites
folders. There's lots of advice out there about configuring Apache using .htaccess
files, and some of it won't work under OS X because Apache is locked down a bit by default.
For example, if you want to have PHP files ending with .html
or .htm
, most people will tell you to create an .htaccess
file and put in it the line:
AddType application/x-httpd-php .html .htm
If you're a developer and this is annoying you, you may want to edit the file /etc/apache2/users/<myusername>.conf
and change the line:
AllowOverride None
to:
AllowOverride All
This will allow your local .htaccess
files to override various global defaults that they couldn't before.