How do I install lighttpd on my Raspberry Pi? I tried running sudo apt-get install lighttpd, which works fine on a regular Debian 'squeeze' installation, but on a Raspberry Pi I get the following error:

Unpacking lighttpd (from .../lighttpd_1.4.28-2+squeeze1_armel.deb) ...
Processing triggers for man-db ...
Setting up lighttpd (1.4.28-2+squeeze1) ...
chown: invalid user: `www-data:www-data'
dpkg: error processing lighttpd (--configure):
 subprocess installed post-installation script returned error exit status 1
configured to not write apport reports
                                      Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

1 Answer 1


The error you see is because you don't have a www-data user and group, but lighttpd expects to find one. So first, add a www-data user and group:

sudo adduser --system --group www-data 

Then you can install lighttpd

sudo apt-get install lighttpd

And that's it. Browse to your Pi's IP address (or localhost on your Pi itself), and you'll be greeted with... a 403 error??

By default, lighttpd installs with an index.php file, but we don't have PHP support installed. This is easy to fix, but the path you take depends on whether or not you want PHP support.

If you don't want to use PHP

  1. Delete /var/www/index.php
  2. (Optional) Edit /etc/lighttpd/lighttpd.conf and remove index.php from index-file.names. In other words, type this:

    sudo nano /etc/lighttpd/lighttpd.conf

    then change this:

    index-file.names    = ( "index.php", "index.html",
                            "index.htm", "default.htm",
                           " index.lighttpd.html" )

    to this:

    index-file.names    = ( "index.html",
                            "index.htm", "default.htm",
                           " index.lighttpd.html" )

That'll stop stray index.php files from causing a 403 error in future.

If you want to use PHP

Install the php5-cgi package:

sudo apt-get install php5-cgi

Enable FastCGI and PHP in lighttpd:

sudo lighty-enable-mod fastcgi
sudo lighty-enable-mod fastcgi-php

Restart the lighttpd daemon:

sudo service lighttpd force-reload
  • Thats odd, I'd expect apt/dpkg to create users by itself. It does so on my server with apache, tomcat and various other servers. So maybe lighthttp is the odd one or you may have stumbled on a RPi bug.
    – Joost
    Jul 3, 2012 at 8:36
  • @Joost This does sound like a bug to me! Jul 3, 2012 at 9:48
  • Yes, I'd expect apt to create and required users too – but it doesn't. Jul 3, 2012 at 9:50
  • @SimonWhitaker You should contact the upstream maintainer - I have no idea how though. Jul 3, 2012 at 9:50
  • 1
    Bug report filed: bugs.debian.org/cgi-bin/bugreport.cgi?bug=680130 Jul 3, 2012 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.