Saturday, April 18, 2009

Bulding Lighttpd 1.5.0 r2914 on MAC OS X Leopard

I haven't blogger for almost a year and it's time to start sharing my experience from the past months again.

Last week I went into trouble trying to build/compile Lighttpd 1.5.0 (latest prerelease r2914) on Mac OS X for test purposes.
One of the major features of Lighty 1.5.0 is the mod_uploadprogress, but unfortunately it is avaialable only in 1.5.0 version for now. So I was desparate to build it. :) (see mod_uploadprogress in action here)

What happened. After downloading the r2914 I ran the configure script with:
./configure --with-zlib --with-bzip2 --prefix=/usr/local/lighttpd --with-lua --sysconfdir=/usr/local/lighttpd/etc

(oh, yeah I wanted mod_magnet, too, to emulate Apache's mod_negotiation, so I added --with-lua)

All went ok with the configure, but then the make exits with:

Undefined symbols:
  "_network_get_backends", referenced from:
      _mod_status_handle_server_config in mod_status.o
  "_network_get_backend_info_by_type", referenced from:
      _mod_status_handle_server_config in mod_status.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[4]: *** [mod_status.la] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2


Ok, so now what? :) Of course, googling, googling and finally I got it! Hurray! :)
A patch was released on 07/08/2008 (download it directly from here), but why it is not applied in the official prerelease? Hm.. I hope the guys from Lighttpd's team will fix this in future.

Building Lighttpd 1.5.0 r2419 and later with applied patch for Mac OS X platform:
(directions for users that are not so much into command line tools)

1) Download and install XCode (if you already have it skip this step)
3) Extract Lighty
4) Download patch and copy it to Lighty's folder
5) Run following commands inside Lighty's folder to apply the patch:

patch -p1 < 0001-fix-build-on-mac-os-x.patch
aclocal
autoheader
glibtoolize --automake --force
automake --add-missing --force
autoconf

6) Configure Lighty with:
./configure --with-zlib --with-bzip2 --prefix=/usr/local/lighttpd

if you need mod_magnet install LUA 5.1 with fink (command: sudo fink install lua51) and configure with:
./configure --with-zlib --with-bzip2 --prefix=/usr/local/lighttpd --with-lua --sysconfdir=/usr/local/lighttpd/etc

7) Build Lighty:
make

8) Install Lighty:
sudo make install

9) Now you have Lighttpd 1.5.0 installed into /usr/local/lighttpd
10) Enjoy!