PHP in Mac OS X: PHP loads source code in browser rather than executing…

apache-2.2httpdmac-osxPHP

I don't know what to do. I read the related question on stackoverflow just like mine but those changes didn't work. I asked again on stackoverflow and they sent me here. They sent that I need to load my PHP module, but I've done that (at least to my knowledge). Here is what I posed to them:

First, I edited the httpd.conf file and uncommented LoadModule php5_module libexec/apache2/libphp5.so .

Next after getting this error "/usr/sbin/apachectl: line 82: ulimit: open files: cannot modify limit: Invalid argument" I changed ULIMIT_MAX_FILES="ulimit -S -n ulimit -H -n to ULIMIT_MAX_FILES="" or some odd thing. That resolved that error.

However I still just see my source code in Safari (actually Chrome decided to download the PHP file instead–different problem/story). Then I found a question similar to mine on stackoverflow and added some AddHandler lines to the php5.conf file which mimicked the AddType lines in the file after AddHandler. Still didn't work even after a "sudo apachectl restart".

Then I finally added AddType x-httpd-php .php to the httpd.conf file because that was also mentioned in the previous question on stackoverflow. I did it just for good measure. Nada.

I'm baffled. I'm just trying to get started so I can learn to program and I feel like I've spent a lifetime just trying to print 'Hello World' in my browser.

Best Answer

If you're looking to program, and want something that 'just works', you may consider just doing a MAMP (Mac, Apache, MySQL, PHP stack) install and moving on. I've used it a few times under Leopard and it did the trick.