Lighttpd 403 Forbidden for PHP 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11537888/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Lighttpd 403 Forbidden for PHP files
提问by Scott
I've just installed lighttpd on my dedicated server, mod_fastcgi is enabled, so I've appended the following lines to the lighttpd.conffile:
我刚刚在我的专用服务器上安装了 lighttpd,启用了 mod_fastcgi,所以我将以下几行附加到lighttpd.conf文件中:
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/tmp/php-fastcgi.socket",
"bin-path" => "/usr/local/bin/php-cgi"
)
)
)
But it still doesn't help, since I'm getting the 403 - Forbiddenmessage when I try to enter a PHP file in my web browser... When I delete the index.phpfile from my web root directory and place the index.htmlthere, then everything is fine, and there are no errors, no matter if index.phpfile has 100 lines or just one - <?php echo 'test'; ?>it always is showing up an 403 - Forbidden, I'm out of ideas now.
但这仍然没有帮助,因为403 - Forbidden当我尝试在 Web 浏览器中输入 PHP 文件时收到消息...当我index.php从 Web 根目录中删除该文件并将其放在index.html那里时,一切都很好,并且没有错误,无论index.php文件有 100 行还是只有 1 行 -<?php echo 'test'; ?>它总是显示一个403 - Forbidden,我现在没有想法了。
Why does it happend?
为什么会发生?
ls -laof my web root directory:
ls -la我的网络根目录:
#
total 6
drwxr-xr-x 15 root wheel 1536 Jul 18 10:23 .
drwxr-xr-x 4 root wheel 512 Jul 18 08:45 ..
drwxr-xr-x 2 www www 512 Jul 1 02:36 cache
drwxr-xr-x 2 www www 512 Jul 1 02:36 config
drwxr-xr-x 6 www www 512 Jul 1 02:36 inc
-rw-r--r-- 1 www www 9 Jul 18 11:02 index.php
采纳答案by Maidenone
Your php is not configured correctly. check your lighttpd error.log it will state something like:
您的 php 配置不正确。检查您的 lighttpd error.log 它将说明如下内容:
(mod_fastcgi.c.1397) [ERROR]: spawning fcgi failed.
i use:
我用:
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"
)))
make sure that fastcgi is enabled in modules.conf
确保在 modules.conf 中启用了 fastcgi
server.modules = (
"mod_access",
"mod_fastcgi",
# "mod_alias",
# "mod_auth",
# "mod_evasive",
# "mod_redirect",
# "mod_rewrite",
# "mod_setenv",
# "mod_usertrack",
)
回答by Tomá? Mika
Same issue, the fix for Mint was install php5-cgi package. sudo apt-get install php5-cgi
enable fastcgi modules sudo lighttpd-enable-mod fastcgi fastcgi-php
and finally reload sudo service lighttpd force-reload
同样的问题,Mint 的修复是安装 php5-cgi 包。sudo apt-get install php5-cgi
启用 fastcgi 模块sudo lighttpd-enable-mod fastcgi fastcgi-php
并最终重新加载sudo service lighttpd force-reload
回答by max kaplan
I had the same issue. The fix was as simple as moving the config files so there were enabled. All I did was...
我遇到过同样的问题。修复就像移动配置文件一样简单,以便启用。我所做的只是...
$ ln -s /etc/lighttpd/conf-available/10-fastcgi.conf /etc/lighttpd/conf-enabled/
$ ln -s /etc/lighttpd/conf-available/15-fastcgi-php.conf /etc/lighttpd/conf-enabled/
and reload...
并重新加载...
$ service lighttpd force-reload
回答by Geom16
On ubuntu you can do this:
在 ubuntu 上你可以这样做:
sudo lighty-enable-mod fastcgi
sudo lighty-enable-mod fastcgi-php
回答by Scryptronic
Unlikely, but should be noted as another possible reason for "403 Forbidden" responses.
不太可能,但应注意作为“403 Forbidden”响应的另一个可能原因。
Check for any access module (mod_access) statements in the config file (lighttpd.conf)
检查配置文件 (lighttpd.conf) 中的任何访问模块 (mod_access) 语句
Example:
例子:
url.access-deny = ( "", ".php");

