I installed lightpd on a Raspberry Pi (running Raspbian Stretch) in this way:
apt-get install -y lighttpd php-common php-cgi php
lighty-enable-mod fastcgi-php
usermod -aG www-data piafter starting the service I checked and it worked fine, serving the php web pages as expected. After rebooting the service doesn't start anymore:
$ systemctl status lighttpd.service
● lighttpd.service - Lighttpd Daemon Loaded: loaded (/lib/systemd/system/lighttpd.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Sat 2017-09-09 21:26:39 CEST; 6min ago Process: 1302 ExecStart=/usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf (code=exited, status=255) Process: 1295 ExecStartPre=/usr/sbin/lighttpd -tt -f /etc/lighttpd/lighttpd.conf (code=exited, status=0/SUCCESS) Main PID: 1302 (code=exited, status=255)
Sep 09 21:26:38 rpi systemd[1]: lighttpd.service: Failed with result 'exit-code'.
Sep 09 21:26:39 rpi systemd[1]: lighttpd.service: Service hold-off time over, scheduling restart.
Sep 09 21:26:39 rpi systemd[1]: Stopped Lighttpd Daemon.
Sep 09 21:26:39 rpi systemd[1]: lighttpd.service: Start request repeated too quickly.
Sep 09 21:26:39 rpi systemd[1]: Failed to start Lighttpd Daemon.
Sep 09 21:26:39 rpi systemd[1]: lighttpd.service: Unit entered failed state.
Sep 09 21:26:39 rpi systemd[1]: lighttpd.service: Failed with result 'exit-code'.Here the configuration file:
$ cat /etc/lighttpd/lighttpd.conf
server.modules = ( "mod_access", "mod_alias", "mod_compress", "mod_redirect",
)
server.document-root = "/home/pi/www"
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
server.errorlog = "/var/log/lighttpd/error.log"
server.pid-file = "/var/run/lighttpd.pid"
server.username = "www-data"
server.groupname = "www-data"
server.port = 80
index-file.names = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
compress.cache-dir = "/var/cache/lighttpd/compress/"
compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" )
# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"What should I check?
3 Answers
You should check that if any directory it's going to use is not mounted to a tmpfs system. Lighttpd is not able to recreate them after installing.
The solution is then to manually create on every reboot the following directories:
/var/log/litghtpd/var/run/lighttpd
owning them as www-data.
Try to disable selinux by typing setenforce 0 and then restart lightpd to check if it works. If it does then edit nano /etc/selinux/config and change the value of SELINUX from enforcing to disabled in order to permanently disable selinux. Very often on Linux os' SELINUX is preventing web servers from starting.
To check configuration: lighttpd -t -f lighttpd.conf
To start in foreground with logging on stdout: sudo lighttpd -D -f lighttpd.conf
More info: