重启后 Lighttpd 无法启动

重启后 Lighttpd 无法启动

我在 Raspberry Pi(运行 Raspbian Stretch)上安装了 lightpd,方法如下:

apt-get install -y lighttpd php-common php-cgi php
lighty-enable-mod fastcgi-php
usermod -aG www-data pi

启动服务后,我检查了一下,发现它运行正常,可以按预期提供 php 网页。重启后,服务不再启动:

$ 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'.

这里是配置文件:

$ 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"

我应该检查什么?

答案1

您应该检查它要使用的任何目录是否未安装到 tmpfs 系统。Lighttpd 在安装后无法重新创建它们。

解决方案是在每次重启时手动创建以下目录:

  • /var/log/litghtpd
  • /var/run/lighttpd

拥有它们作为www-data

答案2

尝试通过键入禁用 selinux setenforce 0,然后重新启动 lig​​htpd 以检查它是否有效。如果有效,则编辑nano /etc/selinux/config并将 SELINUX 的值从 更改enforcingdisabled以永久禁用 selinux。在 Linux 操作系统上,SELINUX 经常会阻止 Web 服务器启动。

答案3

检查配置:lighttpd -t -f lighttpd.conf

要在前台启动并在标准输出上进行登录:sudo lighttpd -D -f lighttpd.conf

更多信息:https://redmine.lighttpd.net/projects/1/wiki/TutorialConfiguration

相关内容