【发布时间】:2014-06-16 22:01:56
【问题描述】:
我在这个问题上花费了几个小时,尽管与它相关的帖子数量很多,但我无法解决它。我有一个带有 Nginx + PHP-FPM 的 Fedora 20 盒子,直到今天它都运行良好(我猜是在我重新加载 php-fpm.service 之后)。 Nginx 提供静态文件没有问题,但是任何 PHP 文件都会触发 403 错误。
权限ok,nginx和php-fpm都在用户“nginx”下运行:
root 13763 0.0 0.6 490428 24924 ? Ss 15:47 0:00 php-fpm: master process (/etc/php-fpm.conf)
nginx 13764 0.0 0.1 490428 7296 ? S 15:47 0:00 php-fpm: pool www
nginx 13765 0.0 0.1 490428 7296 ? S 15:47 0:00 php-fpm: pool www
nginx 13766 0.0 0.1 490428 7296 ? S 15:47 0:00 php-fpm: pool www
nginx 13767 0.0 0.1 490428 7296 ? S 15:47 0:00 php-fpm: pool www
nginx 13768 0.0 0.1 490428 6848 ? S 15:47 0:00 php-fpm: pool www
提供的文件也已设置为 nginx 用户,我什至结束了 chmoding 777 尝试这些文件,但对于任何 PHP 文件仍然“拒绝访问”。
下面是我的 Nginx 配置的服务器:
server {
listen 80;
server_name localhost;
root /var/www/html;
location ~ \.php$ {
fastcgi_intercept_errors on;
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
PHP-FPM 池:
[www]
...
listen = 127.0.0.1:9000
user = nginx
group = nginx
...
对于版本:
php-5.5.11(当然还有 php-fpm-5.5.11)
nginx-1.4.7
我正在添加 Nginx 错误日志:
FastCGI sent in stderr: "Access to the script '/var/www/html' has been denied (see security.limit_extensions)" while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: localhost, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "xxx.xxx.xxx.xxx"
准确地说security.limit_extensions 是正确的,设置为:security.limit_extensions = .php。
关于路径权限,/var/www/html可以遍历。 我错过了什么?
【问题讨论】:
-
我知道这听起来很奇怪,但是您是否仔细检查过您是否编辑了有关limit_extensions 的正确php.ini 文件?前几天我犯了这个错误..
-
limit_extensions仅存在于 FPM 池中,对我而言,/etc/php-fpm.d/www.conf中的 Fedora 20.. 但谢谢约翰 -
您是否尝试过将
fastcgi_pass设置为套接字地址而不是服务器地址(例如 unix:/var/run/php-fpm/php-fpm.sock;)? -
是的,我也试过了,但结果是一样的。我对这个问题的想法已经用完了..
-
嗯..你能把
fastcgi_param SCRIPT_FILENAME设置为$fastcgi_script_name,重新加载fpm然后再试一次吗?没有$document_root...
标签: nginx permissions fedora php http-status-code-403