Lighttpd

Lighttpd is a highly-configurable, lightweight web server. See lighttpd and http://www.lighttpd.net/. There are many modules available for lighttpd that can be installed and configured. For more information on the modules see http://redmine.lighttpd.net/projects/lighttpd/wiki/docs. This article explains how to get lighttpd working on OpenWrt.

Requirements

Execute

opkg list lighttpd*
to see what packages are available.

Installation

opkg

opkg update
opkg install lighttpd

Configuration

Edit /etc/lighttpd/lighttpd.conf

Basic Configuration

To get a basic server running make the following changes to /etc/lighttpd/lighttpd.conf:

Server Root Directory

server.document-root = "/www1/"

where www1 is the root directory of the web server.

Enable Logging

Uncomment (remove #) the following line so errors are written to the log:

server.errorlog = "/var/log/lighttpd/error.log"

Set Server Port

Uncomment the following line:

server.port = 8000

where 8000 is the port you want your webserver on.

Advanced Configuration

Configure as a full LAMP stack

Configuring Lighttpd and PHP5

  1. First, follow php to install a version of PHP
  2. Second, follow lighttpd1 to configure lighttpd
  3. Third, to get PHP running with Lighttpd you need to install the package 'lighttpd-mod-cgi'

Start on boot

To enable/disable start on boot:
/etc/init.d/lighttpd enable this simply creates a symlink: /etc/rc.d/S90umurmur → /etc/init.d/umurmur
/etc/init.d/lighttpd disable this removes the symlink again

To start the server one time: /etc/init.d/lighttpd start To stop the server again: /etc/init.d/lighttpd stop

Firewall

To allow users on the WAN to access the server, make sure to configure the firewall in /etc/config/firewall and port forwarding settings.

config redirect option src wan option src_dport 80 option dest lan option dest_ip 192.168.1.1 option dest_port 8000 option proto tcp config rule option src wan option dest_port 8000 option target ACCEPT option proto tcp

Restart the firewall with the following command: /etc/init.d/firewall restart

Administration

TODO: directory, etc.

Troubleshooting

Incorrect Event Handler

If you get the following error:

(server.c.1105) fdevent_init failed,

you might need to set the event handler explicitly for your system. Add the following line to the configuration file:

server.event-handler = "poll"

See http://redmine.lighttpd.net/projects/lighttpd/wiki/Server.event-handlerDetails

Notes

  • Note that lighttpd does not support .htaccess files as some web servers do to configure directory specific server settings. Instead, it uses a centrally configured system using lighttpd.conf to define all settings, using powerful matching functions. This still means that you have to manually set up directory settings. Especially for (opkg) packages that supply .htaccess files to define required settings. Allowing directory listings is one example that should be disabled or enabled as per the required security level.

Back to top

doc/howto/http.lighttpd.txt · Last modified: 2013/08/11 22:18 by grabbel