Skip to Content

Apache and PHP on a Mac

os x apache phpOne of the very first cool things I learned about the guts of OS X was the existence of Apache, an industrial-strength web server, built in to the OS. O'Reilly has a nice piece on getting started with Apache, so start there if you're new to web serving on your Mac. Imagine hosting your own pages for your own home intranet. Now take that one step further, and imagine dynamic pages, ones capable of accessing data from the web or your machine, on your home network (or using DynDNS, anywhere).

I'm going to point out a few resources for getting started using Apache and PHP on your Mac. You'll find the combination powerful, and getting up to speed is relatively simple. There's some programming involved, so if you're scared of that sort of thing, check out How to Think Like a Computer Scientist: Learning with Python. Granted, you'll be learning Python, but guess what? You can use Python on your Mac as well. Python goes beyond  web programming, and is a great language to get familiar with. If you want to learn PHP, check out Webmonkey's PHP section, or W3 School's PHP intro.

Apple has a page on getting PHP working on your Mac. It's a nice article too, with a step-by-step building of a page to view your iTunes library, complete with plenty of XML goodness as well. The problem here is the version of PHP that comes with your Mac is generally a version behind the current release. While PHP 4.3 was nice, version 5 adds some great stuff. The version of Apache shipping with your Mac probably isn't the latest rev of that either, so check out phpmac's tutorial on installing Apache 2.20 and PHP 5.1.2. It's only for OS X version 10.4.4, but it'll still work with 10.4.5 (no warranty expressed or implied, back up your data, etc.).

Once you have more current versions up and running, try out some of those programming resources, and try building apps. I think you'll find while Apache keeps your Mac acting like a great web page server, PHP can turn your private pages into real network apps. What's really great about setting up PHP on your Mac isn't just a home network, but being able to build and test web apps too, all from the comfort of your favorite OS.

One of the very first cool things I learned about the guts of OS X was the existence of Apache, an industrial-strength web server, built in...
 

Add a Comment

*0 / 3000 Character Maximum

14 Comments

Filter by:
mikel egurra

i'm also using MAMP as a testing ground.
it works just perfect and couldn't be easier to set up.

February 22 2006 at 11:11 PM Report abuse rate up rate down Reply
Eric Kiel

I've written an article for Securing MAMP on my site check it out.

http://machinaproject.dyndns.org/2006/02/19/how-to-secure-mamp/

February 21 2006 at 12:05 PM Report abuse rate up rate down Reply
Jack

As much as I love tinkering with UNIX, what I don't like about Apple's built in Apache is how--with every update--the preferences revert to default preferences. It's tough enough to be a web developer without having to deal with stuff like that.

Instead--and as others have recommended--I highly recommend using MAMP as a development and serving platform. It comes with the lastest version of Apache and has PHP and MySQL built in. It even has phpMyAdmin already set. Simply download it, launch it and you have an instant setup.

I used to use the Entropy packages, but MAMP suits all of my needs.

February 20 2006 at 10:08 PM Report abuse rate up rate down Reply
Robert Jung

As long as we're geeking on Apache/PHP development on Mas, does anyone have a reliable way to activate Apache's mod_rewrite for the MacOS X's installation of Apache? I use that in a lot of the stuff I develop, but I have to use workarounds when on the Mac because I can't figure out how to enable it. (I'm using MacOS X 10.3.9, for what it's worth)

And another vote for Marc Liyange's binary distribution PHP package; not only is it easy-peasy to use, it includes the GD graphics library, which is a bonus for graphically-oriented web development.

--R.J.

February 20 2006 at 6:54 PM Report abuse rate up rate down Reply
Melvin Rivera

sorry. i missed the url instructions. here they are:

step 1 - php and mysql : http://allforces.com/2005/08/22/wordpress-on-mac-phpandmysql/
step 2 - subdomains : http://allforces.com/2005/08/23/wordpress-on-mac-subdomains/

February 20 2006 at 4:03 PM Report abuse rate up rate down Reply
Melvin Rivera

this All Forces tutorial on WordPress on Mac covers installation of PHP and MySQL. Part 2 covers setting up local sub-domains.

February 20 2006 at 3:59 PM Report abuse rate up rate down Reply
George Brett

Last February, Ward Mundy at Nerd Vittles did a great series "how to" about setting up an "ISP in a Box" with the box being a Mac Mini. Still worth reading.
http://mundy.org/blog/index.php?p=23

February 20 2006 at 1:04 PM Report abuse rate up rate down Reply
Patrick Gibson

One reason people commonly install Apache + PHP on their Macs is to test and develop websites on which they're working. To ensure absolute paths work properly as they would on a production server, virtual hosting needs to be employed. I have created a shell script that makes it easy to add as many virtual hosts as you want to your computer. Note that this script is intended for Apache 1.3.x:

http://patrickg.com/virtualhost

February 20 2006 at 12:33 PM Report abuse rate up rate down Reply
Dogzilla

One other thing: PHP isn't just an Apache Plugin. It's also a stand-alone CGI (the Entropy version comes with it, available at /usr/local/php5/bin/php . What's cool about this is you can call this to run non-web scripts just like you would with Perl or Python or Ruby.

There's even a couple of apps that will let you attach user interfaces to your PHP scripts: Platypus (http://sveinbjorn.sytes.net/platypus) and Pashua (http://www.bluem.net/downloads/pashua_en/). I've had a blast with these.

February 20 2006 at 12:20 PM Report abuse rate up rate down Reply
Ken R

Yes, the Entropy installer is really great. I haven't used MAMP, and I don't really care what I do to my OS configuration :)

February 20 2006 at 11:28 AM Report abuse rate up rate down Reply
Buy an ad here

Hot Apps on TUAW

Tweets

© 2012 AOL Inc. All Rights Reserved.