Book Image

Lighttpd

By : Andre Bogus
Book Image

Lighttpd

By: Andre Bogus

Overview of this book

Table of Contents (20 chapters)
Lighttpd
Credits
About the Author
About the Reviewer
Preface
HTTP Status Codes

Installing Lighttpd


Lighttpd has very little dependencies considering the wealth of functionalities it provides. For most systems, getting Lighttpd is just a matter of downloading and installing a package. Before we go out and get one, we better know what we want. There are two branches of Lighttpd: a stable branch and a development branch.

The stable branch is very solid and changes at the most once every two months (if bug fixes are not counted, then about once a year), allowing the developers to concentrate on bug fixes. The development branch moves faster, with a new release every four to six weeks. The development snapshots contain new shiny features, but can also contain hidden bugs, break old features and can generally be less stable.

At the time of writing, version 1.4.19 is deemed to be the stable version, while pre-releases of the upcoming 1.5.0 version are distributed for more testing before the final release. Some systems might have packages of older versions, but anything older than the stable branch many contain known security holes.

For a live server, or if we want the latest versions, we usually compile Lighttpd from sources. For a development server, we might take the easy route and install a precompiled package to leave the worries about dependencies to whoever maintains the package database.

The last question is, on which system we should use Lighttpd? My pragmatic advice is to use what you have. For a development system, take the platform you currently work on. For integration and production platforms, this advice needs to be constrained a little—apart from Windows, which allows too little connections to be open in parallel, most operating systems are suitable for production use—the POSIX-implementing ones (Linux, every BSD, Solaris, Mac OS X, and so on) also benefit from numerous optimizations.

Now, without further ado, here is a list of binary packages per system:

System

Download address or command

Debian GNU/Linux, Ubuntu, Knoppix, other Derivatives

apt-get install libpcre3

apt-get install zlib1g

apt-get install mysql-common libmysqlclient12

apt-get install lighttpd lighttpd-doc

Fedora / Red Hat Novell / SuSE Linux other RPM-based distributions

yum install pcre

yum install zlib

wget http://www.kevindustries.com/media/kw/files/linux/lighttpd/RPMS/lighttpd-1.4.13-3.KWEL4.i386.rpm

Gentoo Linux

emerge lighttpd

Windows

http://www.kevinworthington.com:8181/?cat=20

To compile Lighttpd from source, download the latest source package from http://lighttpd.net/download/. Between Lighttpd versions 1.4.19 and 1.5.0, the build system has changed from Autotools to CMake. Before we can install it, we need the following:

  • A compiler and toolchain—most systems have gcc make and a libc (usually glibc) providing the usual functions. For some embedded platforms, the need to define some constants by hand before cross-compiling has been observed.

  • PCRE—the libpcre package (http://www.pcre.org) supplies PERL-compatible regular expressions to Lighttpd. Lighttpd will run without it, but won't do anything more complex than serving web pages directly under only one hostname and path, without any rewriting or redirecting.

Apart from these, there are some optional packages that expand the capabilities of Lighttpd:

  • OpenSSL (http://openssl.org) or any other SSL library (but OpenSSL is the most-tested one) is needed for transport layer encryption, so our site can be accessed via https.

  • zlib (http://www.zlib.org) is required for mod_compress to supply on-the-fly gzip compression for static content. As virtually every system has zlib available, this should not concern us.

  • bzip2 (http://www.bzip.org) can also be used by mod_compress static content for clients who allow bzip2 compression. It is a little slower than zlib, but achieves higher compression rates.

  • Lua (http://www.lua.org) is a small, fast, powerful scripting language, which is a perfect match for Lighttpd and can be embedded as mod_magnet.

  • MySQL (http://www.mysql.org) is a product by the company that employs the author of Lighttpd. Therefore, it is no surprise that Lighttpd uses MySQL for database-backed virtual hosting. Also, under Debian, a binary install depends on MySQL.

  • pkg-config (http://pkgconfig.freedesktop.org) is not strictly necessary, but it will make the installation easier. Especially for Lua, the Lighttpd installation process relies on it unless given explicit library paths.