Permissions Lighttpd:specific~user目录404
我正在尝试让用户目录在ArchLinux上与Lighttpd一起工作。但在创建public_html目录、在其中放置index.html文件、设置权限、配置Lighttpd以使用用户目录模块并重新启动Lighttpd之后,它仍然为一个特定用户提供404(还有一个用户可以使用) 以下是我的配置文件:Permissions Lighttpd:specific~user目录404,permissions,directory,http-status-code-404,lighttpd,Permissions,Directory,Http Status Code 404,Lighttpd,我正在尝试让用户目录在ArchLinux上与Lighttpd一起工作。但在创建public_html目录、在其中放置index.html文件、设置权限、配置Lighttpd以使用用户目录模块并重新启动Lighttpd之后,它仍然为一个特定用户提供404(还有一个用户可以使用) 以下是我的配置文件: $ cat /etc/lighttpd/lighttpd.conf # This is a minimal example config # See /usr/share/doc/lighttpd #
$ cat /etc/lighttpd/lighttpd.conf
# This is a minimal example config
# See /usr/share/doc/lighttpd
# and http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptions
server.port = 80
server.username = "http"
server.groupname = "http"
server.document-root = "/srv/http"
server.errorlog = "/var/log/lighttpd/error.log"
dir-listing.activate = "enable"
index-file.names = ( "index.html" )
mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".css" => "text/css",
".js" => "application/x-javascript",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".gif" => "image/gif",
".png" => "image/png",
"" => "application/octet-stream"
)
include "conf.d/userdir.conf"
include "conf.d/cgi.conf"
$ cat /etc/lighttpd/conf.d/userdir.conf
server.modules += ( "mod_userdir" )
userdir.path = "public_html"
这就是用户aardbei的情况:
$ cat /home/aardbei/public_html/index.html
doot doot
$ ls -ld /home/aardbei/public_html
drwxrwxrwx 2 aardbei aardbei 4096 Mar 27 13:10 /home/aardbei/public_html
$ ls -ld /home/aardbei/public_html/index.html
-rwxrwxrwx 1 aardbei aardbei 37 Mar 27 13:11 /home/aardbei/public_html/index.html
但是,即使在使用sudo systemctl restart lighttpd重新启动服务器之后,我仍然在URI/~aardbei/index.html中得到404,而不是我应该得到的:“doot doot”
但是,这就是用户madeline的情况:
$ cat /home/madeline/public_html/index.html
blah blah blah
$ ls -ld /home/madeline/public_html/
drwxrwxrwx 19 madeline madeline 4096 Mar 27 13:33 /home/madeline/public_html/
$ ls -ld /home/madeline/public_html/index.html
-rw-r--r-- 1 madeline madeline 15 Mar 27 13:33 /home/madeline/public_html/index.html
所以重要的部分是相同的。然而,去URI/~madeline/index.html
做它应该做的事情:它显示“废话废话”
此处没有任何相关内容,但以下是两个用户的组:
$ groups madeline
wheel video audio wireshark madeline
$ groups aardbei
wheel aardbei
发生了什么事?为什么用户aardbei的用户目录不能在Lighttpd中工作?按照Arch Linux wiki for Apache上的说明工作:
我仍然不确定我是否理解这里的权限,但它解决了我的问题。接受答案有效的原因是,web服务器正在运行的用户需要访问用户的主目录,以便访问其公共\u html
授予o+x
允许其他用户访问目录中的文件和/或子目录,但不允许他们列出目录的内容。基本上,他们可以通过它,只要他们知道自己在寻找什么,public\uhtml
,但他们无法获得其他内容的列表
例子
这是我的主目录:
$ ls -dl /home/sam
drwx-----x. 3 sam sam 4096 Nov 3 11:08 /home/sam
$ ls -dl /home/sam/public_html
drwxr-xr-x. 2 sam users 4096 Nov 3 11:09 /home/sam/public_html
$ sudo -u lighttpd ls /home/sam
ls: cannot open directory /home/sam: Permission denied
现在,作为web服务器的用户,lighttpd
,无法列出我的主目录的内容:
$ ls -dl /home/sam
drwx-----x. 3 sam sam 4096 Nov 3 11:08 /home/sam
$ ls -dl /home/sam/public_html
drwxr-xr-x. 2 sam users 4096 Nov 3 11:09 /home/sam/public_html
$ sudo -u lighttpd ls /home/sam
ls: cannot open directory /home/sam: Permission denied
但如果他们碰巧知道某个特定目录的名称,则可以看到该目录:
$ ls -dl /home/sam/public_html
drwxr-xr-x. 2 sam users 4096 Nov 3 11:09 /home/sam/public_html
以下是web服务器也可以看到的另一个目录:
$ sudo -u lighttpd ls -ld /home/sam/someotherdir
drwx------. 2 sam users 4096 Nov 3 11:22 /home/sam/someotherdir
public\u html
中的文件也可见:
$ ls -dl /home/sam/public_html/index.html
-rw-r--r--. 1 sam users 3 Nov 3 11:09 /home/sam/public_html/index.html
正常权限适用于此处,因此如果您不希望web服务器看到某些内容,请将其设置为仅对您的用户和组,而不是对所有其他人(其他人)进行读取