Apache, PHP, Mac

Print Friendly

The good news is that since the Mac OS X is based on the BSD flavor of Unix, it comes with things like PHP and Apache. The bad news is that both are pathetically backlevel.

This is fixable, however, and I played with various options late last night. Right now I care more for PHP to be at level 5 than I do for Apache to be a level 2, because I’m just using this to locally host websites that are under development. This site, sutor.com, is the prime project. Everything is pretty much PHP, including WordPress and the photo album, and I wrote the latter myself.

I first got Marc Liyanage’s PHP5 package and this installed simply and easily. It worked for my test.php file. I could not get my files to do anything with this installation under Apache, and I was repeatedly told I didn’t have permission to access my files. I know about Unix and permissions, but nothing seemed to work.

Since I was experimenting, I moved on to try MAMP, which is also a seriously nice package. This is a good combined package for MySQL, Apache, and PHP. The test.php file worked, but my PHP files just displayed as HTML. I couldn’t fix this, and looking at the forums indicated that various other people saw this but no one had any obvious solutions which either applied or worked in my case. I uninstalled MAMP.

I finally got the first solution working by copying the files into my Sites directory. Now I thought I had done this, but I was also playing around with symbolic links. I suspect that’s how I got the permission problem. So PHP5 is working fine with Apache 1 now.

In the fullness of time I think I’ll go back and try MAMP again, making sure I copy everything rather than just do a link. If that doesn’t work, I’ll upgrade to Apache 2 some other way.

I have an environment that works now, but it was a pain. Let me also say that it took some work getting it working under Windows the first time as well. I suspect I’ll end up doing my web development on the Ubuntu side of my dual home environment that is under construction. This makes sense because sutor.com is hosted on Linux. Nevertheless, OS X should be much more current than it is.

Comments, tips, and help on this topic are most welcome.

Update: I did try MAMP again and after copying the files, almost everything worked. The photo album did not, so maybe I can debug that later. I don’t like the idea of putting my working files in the Application/MAMP/htdocs folder. They should be stored under my home directory or in some other private directory away from the applications.


  1. Hi, Bob. If you’re looking for tips on setting up WordPress/MySQL/PHP/Apache in Ubuntu, I just finished writing a guide for this at:


  2. Thanks, Scott, I’ll take a look!

  3. > Nevertheless, OS X should be much more current than it is.
    > Comments, tips, and help on this topic are most welcome.

    Bob, to get the most current versions of Open Source software for the Mac may I suggest you use the MacPorts (formally knows as Darwin Ports) repository. The command line “port” program will download the source files, as well as required dependencies, and compile them. You will need to have Apple’s free developer package installed to do so. If you don’t like to use the command line there is a nice GUI available for $20 called Port Authority. You will be able to install PHP 5.2, Apache 2.2.4, MySQL 5.0.33, and much more. Give it a try there is lots of good stuff available.

  4. I’ve been using MAMP for a few months now and like its ease of use, which is on par with the usual OS X experience. But as you mentioned I also elected to keep my web files outside the MAMP application, as I don’t think data should be in an application folder; simply isn’t elegant, nor practical for backup purposes. I decided to use the /Sites folder and simply change the preferences in MAMP to reflect that.

    In addition, I’ll probably symlink the /mysql directory in the application to have it point somewhere else too, as I don’t want to forget that my sql tables are in there, next time I upgrade MAMP (and it overwrites the directory).

Comments are closed