I have a web server on my mac mini that runs the default (installed with snow leopard) apache2 web server. It works fine for any programming language that outputs stdout for cgi scripts, but every attempt I have made to enable PHP has failed. Please help! I can upload any files that you need to see like php.ini or httpd.conf

I have tried scanning through the php.ini file values, php5 module load is uncommented in the httpd.conf.
These are the only steps that I have seen to enable php on a mac.

php5, from what I hear, is installed by default on Mac OS X snow leopard.

  • Did you access your php files through localhost/~username or through file:///Users/username/Sites/ ? Commented Sep 7, 2013 at 0:27
  • @Matthieu Riegler try this link: zachgottesman.com/t.html that shows what is happening with php (view source of page)
    – zggz12
    Commented Sep 7, 2013 at 1:11

1 Answer 1


You need to include the following directive in your httpd.conf file:

AddType application/x-httpd-php .php


To make this answer more useful for others, the full configuration for php on apache2 is:

LoadModule php5_module libexec/apache2/libphp5.so

Or whatever your path is your php module. This is the default path which come with Mountain Lion. Al I had to do was uncomment it. This is followed in the apache2.conf file with:

<IfModule php5_module>
    AddType application/x-httpd-php .php
  • That is exactly what I needed. Thank you so much. And this is why I love stackexchange sites: A problem I have had for years, is solved in a few days!
    – zggz12
    Commented Sep 7, 2013 at 21:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .