Lighttpd静态文件服务器403禁止错误

我在Debian Jessie上安装了lighttpd来提供静态文件,我在/ media / storage上安装了一个USB驱动器,将/ media / storage / www作为我的文档根目录,我的lighttpd.conf如下所示:

server.modules = ( "mod_access", "mod_alias", "mod_compress", "mod_redirect", # "mod_rewrite", ) server.document-root = "/media/storage/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" 

我想用我的普通用户“jurre”来编辑网站。 所以我做了“sudo chown jurre:www-data / media / storage / www”和“sudo chmod 740 / media / storage / www”(所以我可以读,写和执行文件,但是web服务器只能读取)。 当然,我退出并重新返回,然后重新启动lighttpd。 我用“Hello World!”添加了一个简单的index.html testing的设置,但我不断收到一个403禁止错误时冲浪到

ls -l in / media / storage / www:

 total 8 -rw-r--r-- 1 jurre www-data 58 May 16 16:43 index.html 

我也检查了lighttpd错误日志,但它只显示Web服务器closures并重新启动时,日志中没有任何错误。

您不能访问您的www文件夹,因为www-data用户只有4权利(用户:组jurre:www-data和权利740),这意味着没有在www文件夹执行权限,只读(读取文件夹名称和属性)。

你需要在文件夹上执行,因为执行一个文件夹意味着打开它(列出文件或input文件)。 你可以用你自己的用户jurre来做这个(右边7),但www-data没有设置执行位。

将此文件夹的权限更改为750,然后重试。

Superpelican,

继上面的评论。 可能要尝试“sudo chown -R www-data:www-data *”“sudo chown -R www-data:www-data / media / storage / www / *”在该文件夹或子文件夹内/ media /存储/万维网这种方式的networking服务器拥有文件夹和文件不是你作为一个用户。

至于chmod ..也尝试用类似“sudo chmod -R 755 / media / storage / www / *”更糟的情况下“ chmod -R 775 ”web服务器和物理服务器之间有不同级别的文件安全操作系统自我。 chown / chmod在操作系统级别更多。 将影响获取服务器上的文件和网页..

希望这有助于..干杯..