From PacBSD Wiki
Jump to: navigation, search

Lighttpd is "a secure, fast, compliant, and very flexible web-server that has been optimized for high-performance environments. It has a very low memory footprint compared to other webservers and takes care of cpu-load. Its advanced feature-set (FastCGI, CGI, Auth, Output-Compression, URL-Rewriting and many more) make lighttpd the perfect webserver-software for every server that suffers load problems."


You can install lighttpd from AUR. You will also need fcgi to build it.

Basic configuration

The lighttpd configuration file is: /usr/local/etc/lighttpd/lighttpd.conf. You might want to use sample config:

cp /usr/local/etc/lighttpd/lighttpd.conf.example cp /usr/local/etc/lighttpd/lighttpd.conf

To check your lighttpd.conf for bugs you can use this command - helps finding misconfigurations very fast:

$ lighttpd -t -f /etc/lighttpd/lighttpd.conf

The default configuration file specifies /srv/http/ as the document directory served.

It may be necessary to add a user and group for http if you do not already have one. That user needs to have write permissions to /var/log/lighttpd as well, so we will make it the owner of the folder:

# pw groupadd -n http
# pw useradd -n http -d /srv/http/ -g http -s /sbin/nologin 
# chown -R http /var/log/lighttpd

To test the install:

# echo 'TestMe!' >> /srv/http/index.html
# chmod 755 /srv/http/index.html

To start the server:

# /etc/init.d/lighttpd start

Then point your browser to localhost, and you should see the test page.

To start the server on every boot:

# rc-update add lighttpd

Example configuration files are available in /usr/local/share/doc/lighttpd/.