lighttpd

On this page 7

lighttpd (pronounced “lighty”) is a lightweight open-source web server designed for high concurrency with a small memory footprint, using a single-threaded, event-driven architecture instead of one process or thread per connection. Among web servers, it occupies the niche between full-featured platforms such as Apache and Nginx and minimal embedded HTTP daemons.

Released under the revised BSD license, lighttpd is common on embedded devices, routers, network appliances and small virtual machines, and it still serves static content and FastCGI applications on general-purpose servers where predictable resource use matters more than a large module ecosystem.

How lighttpd handles connections

lighttpd processes requests in an asynchronous event loop: one main process watches many sockets at once and reacts only when a socket becomes readable or writable. The server relies on the operating system’s scalable event interfaces, such as epoll on Linux, kqueue on BSD and macOS and /dev/poll or event ports on Solaris, with poll and select as portable fallbacks.

Because idle keep-alive connections cost only a small state structure rather than a blocked thread, a single instance can hold thousands of concurrent connections within a few megabytes of RAM. Static files are sent with zero-copy system calls such as sendfile, which move data from the page cache to the socket without passing through user space.

Dynamic content is never executed inside the server. lighttpd forwards such requests to external backends through FastCGI, SCGI, CGI or HTTP proxying, which keeps the core small and isolates application crashes from the web server itself.

The table below lists the main building blocks of a typical lighttpd deployment.

ComponentRoleTypical configuration
Event loopMultiplexes all client socketsserver.event-handler = “linux-sysepoll”
mod_fastcgiPasses requests to FastCGI poolsPHP-FPM socket or spawned processes
mod_proxyForwards requests to HTTP backendsApplication servers on local ports
mod_rewriteRewrites request URLs internallyurl.rewrite-once rules
mod_opensslTerminates TLS connectionsssl.pemfile and ssl.privkey
mod_deflateCompresses responses on the flygzip, deflate, brotli or zstd
Core components of lighttpd

Configuration model and modules

lighttpd is configured through a single file, usually lighttpd.conf, written in a declarative key-value syntax with conditional blocks. Conditionals match on request properties such as $HTTP["host"], $HTTP["url"] or $SERVER["socket"], so virtual hosts, per-directory rules and listening sockets are all expressed with the same construct.

Functionality comes from loadable modules listed in server.modules. There is no per-directory override file comparable to .htaccess, which means every rule change requires editing the central configuration and reloading the server. This design favors performance and predictability over delegated configuration on shared hosting.

The following settings have the greatest effect on capacity and behavior.

SettingPurposeCommon value range
server.max-connectionsCaps concurrent client connections1,024 to 16,384
server.max-fdsLimits open file descriptorsAbout twice max-connections
server.max-keep-alive-requestsRequests allowed per connection100 to 1,000
server.max-keep-alive-idleIdle seconds before closing5 to 30 seconds
server.max-workerNumber of worker processes0 to 4, usually 0
server.stat-cache-engineCaches file metadatasimple or inotify
Key lighttpd settings and their effect

Running more than one worker is possible but rarely needed, because a single event loop can saturate a network link when serving static files. Extra workers mainly help on multi-core systems with TLS-heavy traffic, and they complicate features that keep shared state.

lighttpd compared with other web servers

lighttpd shares its event-driven design with Nginx and Caddy, but it differs in ecosystem size, configuration style and typical deployment. Apache, by contrast, can use process- or thread-based multi-processing modules and supports .htaccess files, which explains its long dominance in shared hosting.

ServerArchitectureTypical strengthMain limitation
lighttpdEvent-driven, single processVery low memory useSmaller community and module set
NginxEvent-driven, multiple workersReverse proxy and load balancingNo per-directory overrides
ApachePrefork, worker or event MPM.htaccess and broad modulesHigher memory per connection
CaddyGo runtime with goroutinesAutomatic HTTPS by defaultLarger binary and memory baseline
OpenLiteSpeedEvent-driven with LSAPIFast PHP through LSAPIPartial .htaccess compatibility
lighttpd and related web servers

In practice, Nginx has displaced lighttpd in most high-traffic web hosting, largely because of its richer proxy, caching and load-balancing features. lighttpd remains the pragmatic choice for constrained hardware, where its binary size and baseline memory use are decisive.

Where lighttpd is used and how to deploy it

lighttpd fits workloads where the server must stay small, stable and easy to audit. Router and network-attached storage firmware, single-board computers, local management dashboards and static asset hosts are typical examples. The lighttpd 1.4 branch is the actively maintained line and has gained HTTP/2 support, modern TLS libraries and current compression algorithms.

The decision table below summarizes when lighttpd is a sensible choice.

SituationRecommendationReason
Embedded device with 64 MB RAMUse lighttpdSmall footprint and predictable memory
Static site on a small VPSlighttpd or NginxBoth serve files efficiently
PHP application via PHP-FPMlighttpd with mod_fastcgiClean separation of web and PHP tiers
Shared hosting with user overridesPrefer ApacheCustomers expect .htaccess files
Complex load balancing and cachingPrefer NginxRicher proxy and cache features
Choosing lighttpd for a workload

A sound deployment runs lighttpd as an unprivileged user after binding to ports 80 and 443, restricts the document root, enables only the modules the site needs and places PHP or Python applications in separate FastCGI or proxy backends with their own resource limits.

Limitations and common mistakes

The main weakness of lighttpd is its smaller ecosystem: fewer third-party modules, fewer tutorials and fewer administrators who know its configuration syntax. Some historic problems, such as a memory leak in older 1.4 releases and the abandoned 1.5 branch, still shape its reputation even though current releases are stable.

SymptomLikely causeFix
Rewrite rules silently ignoredmod_rewrite not loaded or order wrongAdd the module and test rule order
“Too many open files” errorsserver.max-fds set too lowRaise max-fds and the OS ulimit
PHP returns 503 errorsFastCGI backend down or overloadedCheck the socket and process pool size
Slow responses under loadBlocking backend, not the serverScale or tune the application tier
Migrated .htaccess rules failNo per-directory configurationTranslate rules into lighttpd.conf
Frequent lighttpd problems

A frequent misconception is that an event-driven server makes slow applications fast. lighttpd only removes connection overhead; the backend’s throughput still sets the ceiling for dynamic pages.

The short version

lighttpd is a small program that delivers web pages to browsers. Its main advantage is that it needs very little memory and processor power, so it works well on modest hardware such as home routers or tiny servers.

Think of a single waiter who takes orders from many tables by moving quickly between them instead of standing at one table until the meal is finished. That is how lighttpd handles many visitors at once. The key takeaway is that it trades a large feature set for efficiency and simplicity.

Where it makes a difference

A manufacturer of network-attached storage boxes needs a web interface for its devices, which ship with 512 MB of RAM shared by the file system, the sharing services and the management tools. The engineering team chooses lighttpd because the server runs in a few megabytes of memory and its configuration file is short enough to review line by line.

The interface consists of static HTML and JavaScript served directly by lighttpd, while a small management application runs behind mod_fastcgi on a Unix socket. TLS is terminated with mod_openssl using a certificate generated on first boot.

During testing, the web interface stays responsive with hundreds of open browser sessions while a large file copy saturates the disks. The outcome is a management console that never competes noticeably with storage services for memory, which is exactly the constraint the hardware imposes.