11

I have followed several tutorials. Web sharing is on and I uncommented the php module in apache2/httpd.conf, but when I try to open the phpinfo file, it still tries to open it as a file.

Tommy
  • 113
  • 1
  • 1
  • 5
  • What steps did you take and how did you try to open the file? – GordonM Jun 30 '12 at 18:28
  • I added it to the root of my personal website and tried to open it in Firefox. – Tommy Jun 30 '12 at 18:39
  • 1
    Does "the phpinfo file" have ".php" at the end of the filename? What does "the phpinfo file" have in it? – Mark Eirich Jun 30 '12 at 18:47
  • possible duplicate of [How do you get php working on Mac OS X Lion 10.7?](http://stackoverflow.com/questions/6790568/how-do-you-get-php-working-on-mac-os-x-lion-10-7) – Mark Eirich Jun 30 '12 at 18:54
  • I also struggled with getting php/apache to work on lion.. then I found MAMP, this is just awesome for web development: http://www.mamp.info/en/index.html very simple to set up and works like a charm. – MilMike Jun 30 '12 at 19:00
  • Yes the info file has php at the end and I've also tried other php files. – Tommy Jun 30 '12 at 19:05
  • The actual answer which is working is here. This appears to be case when you update your Mac OSX: http://apple.stackexchange.com/questions/211015/el-capitan-apache-error-message-ah00526 – Placeholder Sep 27 '16 at 06:16

2 Answers2

31

Edit your /etc/apache2/httpd.conf and make sure the line:

LoadModule php5_module libexec/apache2/libphp5.so

...exists. I think it's commented out by default in the standard OS X config, but from what I remember, you just need to uncomment it, then re-start Apache:

sudo apachectl restart

And you should be good to go.

OR

use MAMP

http://www.mamp.info/en/index.html

Dave Mascia
  • 1,364
  • 10
  • 14
24

Make sure your Apache config includes this line:

AddType application/x-httpd-php .php
Mark Eirich
  • 10,016
  • 2
  • 25
  • 27
  • On my system it is in a file named php5.conf, but I am using Apache from MacPorts instead of the original... I think I copied my config directly from the original config, though – Mark Eirich Jun 30 '12 at 18:56
  • 1
    You may have to copy /etc/php.ini.default to /etc/php.ini if the latter does not exist. – Mark Eirich Jun 30 '12 at 18:59
  • you can directly add this line within ` ` block – Swaps Aug 19 '16 at 19:39