lighttpd PHP 错误:403 - 禁止

问题描述 投票:0回答:3

我一直在尝试在 Windows 上使用 lighttpd 配置 Web 服务器。安装 PHP 后,每次我尝试从目录“htdocs”访问 PHP 文件时,都会收到错误:“403 - Forbidden”。我已按照本教程设置 lighttpd:http://joshdick.net/writing/lighttpd。我搜索过谷歌,但没有找到关于这个问题的任何好的文档。仅供参考:我对此很陌生。我有我的“lighttpd-inc.conf”文件的内容here.

任何帮助将不胜感激。谢谢!

php lighttpd http-status-code-403
3个回答
1
投票

这可能有很多事情。例如,如果您在 Windows 上使用 FastCGI,则可能存在问题(它们运行不佳)。它可能就像您的文件夹权限(在 Windows 中)不允许访问此文件夹一样简单。但是,在尝试查看您的 .conf 文件之后(缺少换行符使其难以阅读),我有一个您可以开始查找的地方。

看起来你指的是 htdocs 的路径不正确。例如,这里的这一行:

server.document-root = "HTDOCS/"

我不认为这条路会正常工作。通常你必须有一个“/HTDOCS/”风格的路径。整个文件中有许多这样的行。这是一些关于此的文档的链接:

http://redmine.lighttpd.net/wiki/1/server.document-rootdetails


0
投票

你的 php 的 cgi/fcgi 配置不正确。 CGI 或 FCGI 是将 PHP 和 lighttpd 结合在一起的粘合剂。 检查你的 lighttpd error.log 它会说这样的话:

(mod_fastcgi.c.1397) [ERROR]: spawning fcgi failed. 

我用:

fastcgi.server = ( ".php" => ((                                      
                     "bin-path" => "/bin/php-cgi",             
                     "socket" => "/tmp/php.socket",              
                     "max-procs" => 1,                                     
                     "bin-environment" => (                         
                       "PHP_FCGI_CHILDREN" => "16",                    
                       "PHP_FCGI_MAX_REQUESTS" => "10000"           
                     ),         
                     "broken-scriptfilename" => "enable"
                 )))   

确保在 modules.conf 中启用了 fastcgi

server.modules = (
  "mod_access",
  "mod_fastcgi",
#  "mod_alias",
#  "mod_auth",
#  "mod_evasive",
#  "mod_redirect",
#  "mod_rewrite",
#  "mod_setenv",
#  "mod_usertrack",
)

0
投票

看起来你必须启用 fastcgi 模块和 php 配置。要执行该操作,请运行以下命令:

sudo lighty-enable-mod fastcgi
sudo lighty-enable-mod fastcgi-php
sudo systemctl restart lighttpd.service
© www.soinside.com 2019 - 2024. All rights reserved.