最近我开始使用“lighttpd”网络服务器来托管本地网络服务器以放置一些文件。我在 docker 容器中使用 Ubuntu 20.04 机器。我遵循本指南lighttpd。我已经使用 安装了 lighttpd 包apt install lighttpd
。lighttpd.conf
如下所示:
server.modules = (
"mod_indexfile",
"mod_access",
"mod_alias",
"mod_redirect",
)
server.document-root = "/var/www/html"
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
server.errorlog = "/var/log/lighttpd/error.log"
server.pid-file = "/run/lighttpd.pid"
server.username = "www-data"
server.groupname = "www-data"
server.port = 81
server.bind = "localhost"
server.tag = "lighttpd"
# strict parsing and normalization of URL for consistency and security
# https://redmine.lighttpd.net/projects/lighttpd/wiki/Server_http-parseoptsDetails
# (might need to explicitly set "url-path-2f-decode" = "disable"
# if a specific application is encoding URLs inside url-path)
server.http-parseopts = (
"header-strict" => "enable",# default
"host-strict" => "enable",# default
"host-normalize" => "enable",# default
"url-normalize-unreserved"=> "enable",# recommended highly
"url-normalize-required" => "enable",# recommended
"url-ctrls-reject" => "enable",# recommended
"url-path-2f-decode" => "enable",# recommended highly (unless breaks app)
#"url-path-2f-reject" => "enable",
"url-path-dotseg-remove" => "enable",# recommended highly (unless breaks app)
#"url-path-dotseg-reject" => "enable",
#"url-query-20-plus" => "enable",# consistency in query string
)
index-file.names = ( "index.php", "index.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
## Use ipv6 if available
#include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.conf.pl"
include "/etc/lighttpd/conf-enabled/*.conf"
#server.compat-module-load = "disable"
server.modules += (
"mod_compress",
"mod_dirlisting",
"mod_staticfile",
)
我还有一个简单的 HTML 文件/var/www/html/
要显示Hello World!
但是当我使用启动 lighttpd 时,/etc/init.d/lighttpd start
我得到:
(network.c.311) can't bind to socket: 127.0.0.1:81 Address already in use
当我打开浏览器(例如 Chrome)并启动时localhost:81
,它显示This site can’t be reached. localhost refused to connect.
我尝试/etc/init.d/lighttpd stop
并重新启动但结果还是同样的错误。
当我做netstat -ntulp
:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:81 0.0.0.0:* LISTEN -
我预计应该分配一个 PID 给lighttpd
谁能告诉我这里的问题是什么以及如何解决?
提前致谢。
附言:如果这里缺少任何信息,请告诉我。
答案1
看起来该端口81
已被其他应用程序使用。要查看,PID/Program
您应该使用sudo netstat -ntulp
。
您也可以尝试将lighttpd
端口更改为其他端口,83
例如88
......
问候