lighttpd logo
It was time to get some of my local web things working, so I needed to get the web server going on OS X 10.5. Obviously the main candidate is Apache, which is already installed on OS X. But, on my previous Windows laptop I’d gone for lighttpd for similar reasons to these given by Garrett at Ray Gun Robot:

Why install LightTPD when Mac OS X already comes with the Apache web server built in? Well, I suppose it’s a matter of personal taste. I personally like the web server to be running all the time, so that way, when I decide I want to start coding my site, I don’t have to mosey over to a Terminal window or System Preferences to start it up first. On the other hand, since it’s going to be constantly running, the web server should be using up as little RAM and CPU resources as possible. So I want to use a “lightweight” server so that the fact that it’s running all the time won’t interfere too much with my frames-per-second on Call of Duty 2 and stuff. On the other other hand, it can’t be so lightweight that it doesn’t support PHP, which is the point of all of this in the first place, right? So, for me (and possibly for you), LightTPD is the best compromise.

Disappointingly, it’s harder work getting going on the Mac than it was on the PC. For future reference, what I should have done was:

  1. Install Apple’s Xcode tools first (free with the Mac)
  2. Go to MacPorts and install according to these instructions
  3. Sort out the $PATH to make it easier to run commands
  4. Install the lighttpd package with this command: sudo port install lighttpd
  5. Install php5 with fastcgi extension with this command: sudo port install php5 +fastcgi - takes quite a while!

Unfortunately in the long php5 install steps, it failed on libxml2 v2.6.30, with a checksum mismatch. I can discover (using port livecheck libxml2) that the most recent version is v2.6.31, but running the MacPorts port -d selfupdate doesn’t seem to bring in the newer version.

I’m pleased with myself. For a long time I’ve been wanting to get our library of books uploaded onto www.librarything.com, partly because it looks like a good 3rd party service offering that is going to do a better job than I am, and partly because it can show your books as collections of covers.
LibraryThing logo
The downside is that they don’t have an API (programmatic interface) to add lots of books that I can use. They do have an import form where you can add multiple ISBNs in one go, but I haven’t yet got the ISBNs for quite a lot of our books, and for some that I do have the ISBNs don’t turn up in Amazon or their other sources of info.

So I decided to write some PHP to poke the existing “advanced manual add” form with the contents of my book list, held in XML.

Last night I got the POST operation working, after much more effort than I was expecting. Turns out the documentation for the various PHP libraries that deal with HTTP POST operations aren’t as good as I’d like - particularly the PEAR one. In the end I went with cURL, which then took an age to install properly as you have to do odd things with libssl32.dll and libeay32.dll and the windows/system32 directory. Grr. Turns out I needed to have cookie authentication turned on, but otherwise it was fairly straightforward once I figured out the http_build_query function.

Anyway, I’m writing the rest of the code today, so its not yet finished, but the results should be available at our profile - or the view of the books more directly at our catalog (sic).

Welcome to my blog site -- here to help me work out what I think. Feel free to join in, and start a debate. Cheers -- Jonathan.