8

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:
 lighttpd
E: Sub-process /usr/bin/dpkg returned an error code (1)
Simon Whitaker
  • 499
  • 4
  • 8

1 Answers1

6

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
tlhIngan
  • 3,342
  • 5
  • 18
  • 33
Simon Whitaker
  • 499
  • 4
  • 8