On getting lighttpd + PHP working on OS X Tuesday, Mar 2 2010 

Now playing: ♫ One More Time – Daft Punk

My first post of 2010!  I have been so busy that I just haven’t had any time to write anything in here.  But I have something special for you today; some build instructions for making an experimental dev server out of a Mac.

I use a Mac at work.  And being that I frequently have to test out our new Web stuff (some written in PHP but the majority written in Django), it’s helpful to have a working lighttpd install on it.  I’ve considered dual-booting with FreeBSD, but it seems a bit of a challenge to get all of the Apple hardware to work on FreeBSD (especially WiFi; we don’t even really use wired Ethernet at work anymore) so I’ve held that off for a while.  I could also use my desktop, but with the KVM on the fritz I just find it easier to sometimes run sites on OS X.

This isn’t a problem with Django, because it comes with a small development server that I can use.  But it is big problem with PHP; the Apache2 built in to Snow Leopard doesn’t seem to like me or PHP (or my configuration) and I prefer lighttpd anyway.  I could never find a really good guide to installing any of this online without resorting to MacPorts or Fink or even Aptitude.  I prefer to keep my system clean of the port systems (even though I’ve heard great things about MacPorts, it just seems ugh).   So, here’s how I got lighttpd and PHP to play nice on OS X with FastCGI:

Absolute prerequisites

  1. You must be absolutely comfortable with using Terminal and compiling things by hand.
  2. You must have already installed XCode, because we’re going to be using GCC and friends.

lighttpd installation

  1. Install PCRE.  This is the only lighttpd dependency that Mac OS X doesn’t ship developer libs with.
  2. I ran configure like this:
    ./configure --prefix=/usr/local --with-openssl --with-kerberos5 --with-ldap --with-zlib
    This allowed me to test SSL and Kerb5, which we use on one of our portals, and a few other miscellaneous things I feel will be useful.
  3. make and then sudo make install.
  4. Congratulations, you have an almost-working lighttpd!

PHP installation

For GD, you’ll need at least:

  1. libjpeg (Note: You’ll need to run sudo mkdir -p /usr/local/man/man1 for manpages.  If you don’t want them, you can ignore the error Make throws.)
  2. libpng (Don’t you love that they still distribute .TXZ’s?)

You can also snag FreeType and libxpm, but it isn’t necessary and building them is beyond the scope of this document.

Okay, so now we’re ready to build PHP. The configure line you supply to PHP is site-specific.  The one I used was:

./configure --prefix=/usr/local --with-openssl=/usr --with-kerberos --with-pcre-regex=/usr/local --without-sqlite --without-sqlite3 --disable-pdo --with-zlib --with-bz2 --enable-exif --with-gd --with-ldap --with-ldap-sasl --with-mcrypt --without-mysql --with-pgsql=/usr/local/pgsql

but I stress again: this is site-specific. You probably want MySQL and don’t want PostgreSQL (even though it takes a lot to squeeze even equal performance out of MySQL).  That said, the only oddity is that on OS X, PHP has a problem locating the OpenSSL lib for itself and I had to use –with-openssl=/usr to allow it to find where it was.

Also, a big disclaimer: GD is still broken with libpng>=1.3.  Since I use 1.4, I was forced to use the SVN version of 5.3.  Not even the new 5.2.13 release has the patch (even though this bug was reported in early January).

Now that we’ve gotten that out of the way, let’s get a server running!

Configuration files

The lighttpd configuration file is up to you.  Note that you have to use server.event-handler = "freebsd-kqueue" on OS X.  Mine is pretty standard, so I’m only going to paste the FastCGI configuration section here:

fastcgi.server = (
".php" => (
"php-osx" => (
"socket" => "/tmp/php5.sock",
"bin-path" => "/usr/local/bin/php-cgi",
"bin-environment" => (

Now, one of the most painful parts of this process was getting a LaunchDaemon configured for lighttpd properly.  Note that when under launchd, lighttpd is very sensitive to syntax; I spent about an hour trying to figure out why it wouldn’t start until I realised I had an extraneous space in the plist.  Here is my /Library/LaunchDaemons/net.lighttpd.plist file:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
<plist version="1.0">

Now run launchctl as root and type load /Library/LaunchDaemons/net.lighttpd.plist.  If you’ve come this far and you don’t get any errors, congratulations!  Your Mac is now a lighttpd+PHP/FastCGI server!

On GeoCities’ closing Monday, Oct 26 2009 

Now playing: Lady of the Flowers by Placebo on Placebo [1996] (iTunes)

I’ve been so very busy at work the past few days that I had forgotten I signed up for this blog.  I remembered yesterday evening, but couldn’t think of a topic to write about.  However, this morning I was reminded that today is the day GeoCities closes.  And of course, sites like XKCD are parodying the bad HTML and broken images we’ve all grown to hate.

However, I want to remind you of a better time.  The GeoCities of the mid ’90s; the GeoCities I once knew, used, and loved.  Before the commercialisation, before the Yahoo! aquisition, before its own personal “eternal September” of clueless newbies.

GeoCities, circa 1996, before it sucked.

GeoCities, circa 1996, before it sucked.

There was, and still is, a lot of technical information of GeoCities, and a lot of it is rare content that you won’t find anywhere else.  There was more information than you would think, especially on old technologies including GEOS, Roland synthesisers, and RISC CPUs.  There were fansites of good ol’ TV shows…remember Suddenly Susan?  Smart Guy?  Even classic telly, such as Gilligan’s Island and Monty Python’s Flying Circus.  There were MIDI archives.  There were some excellent history and genealogical resources.  And was there a more expansive lyrics archive on the early Web than Andrew’s Lyrics?  (There actually were much better ones on Gopher, but that’s an entirely different subject.)

And GeoCities was the beginning of the social Web revolution, allowing anyone with access to a keyboard the ability to write a Web site about anything, thereby bringing people who wanted to just have a page about their family.  I’ll admit I’m a bit guilty of doing that myself; I signed up for a GeoCities page in 1997, relatively late, and used it primarily for voicing my opinions on computing and showing off my family pictures.  I closed it down in ’99, because I was far too busy being a full-time administrator to keep it up.  Not to mention the commercialisation that came…banner ads and the watermark were just the beginning, as we would all find out when Yahoo! purchased them.  However, that was what proved the fatal flaw with “anyone with a keyboard can sign up”: the general masses gained Internet access, and back then everyone was flooding Yahoo! to get their wide variety of services (primarily for email and messenger).  These masses used terrible, disgusting editors (FrontPage Express, Hot Dog, and even Netscape Composer 4.x generated abysmal HTML) and wrote about nothing in particular.  This made the content rapidly decline in value, turning GeoCities into basically just a pile of meaningless babble and broken HTML, and the only thing declining faster than their reputation and content quality was their real userbase.  So here we are.  Yahoo! is dwindling, they’re strapped for cash, and probably just can’t afford GeoCities anymore.  In the eyes of most, this is a Good Thing™ because of the drivel that most people think GeoCities is famous for.

But I still remember the great big melting pot, the community that was GeoCities in the ’90s.  And though there are some modern hosting providers that are somewhat akin to this old GeoCities in terms of hosting (here are a few), none can match the community. And that is, I think, what GeoCities was for me and many others back then – a community of people from different backgrounds and cultures, sharing the collective of our knowledge (and family pictures) for the world to see.

Fare thee well, old friend.  Here’s to one last <marquee/> tag, and the hope that one day someone may be able to rekindle the community spark of 1995.