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.
Asked
Active
Viewed 1.5k times
11
-
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
-
1Does "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 Answers
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

Dave Mascia
- 1,364
- 10
- 14
-
are you loading your PHP files from your Home folder Sites directory? – Dave Mascia Jun 30 '12 at 18:46
-
-
-
The Apache/PHP installation that comes with the Mac works fine; MAMP is not necessary. – Mark Eirich Jun 30 '12 at 18:50
-
-
-
Shouldn't the link to my site be http://myip/~Username/ instead of http://10.0.0.5/~Username/? – Tommy Jun 30 '12 at 19:47
-
Figured it out. When I change 10.0.0.5 to localhost in my browser it works. Anybody know how I can configure it to allow me to open php files without having to open from my browser? – Tommy Jun 30 '12 at 20:00
-
6I had to do `AddType application/x-httpd-php .php` as Mark said in his comment – Raul Guiu Jun 10 '13 at 15:16
-
saved me at least an hour. was near to slap some people in a fece. – Dmytro Pastovenskyi Oct 01 '15 at 14:05
-
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
-
1You 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
-