NGINX-未指定输入文件。-php fpm
标题中描述了该错误。 问题是使用.php文件可以,但我不能提供.html文件(403错误)NGINX-未指定输入文件。-php fpm,php,nginx,ubuntu-16.04,Php,Nginx,Ubuntu 16.04,标题中描述了该错误。 问题是使用.php文件可以,但我不能提供.html文件(403错误)Nginx和php-fpm像www-data用户一样工作,所有站点目录的所有者组是www-data,我正在测试的文件的权限是775 如果我将index.html重命名为index.php,一切正常 我的vhost配置: server { listen 80; server_name www.martynov.test.kooweb.ru martynov.test.kooweb.ru;
Nginx
和php-fpm
像www-data
用户一样工作,所有站点目录的所有者组是www-data
,我正在测试的文件的权限是775
如果我将index.html
重命名为index.php
,一切正常
我的vhost配置:
server {
listen 80;
server_name www.martynov.test.kooweb.ru martynov.test.kooweb.ru;
root /home/martynov/www/test.kooweb.ru;
access_log /var/log/nginx/martynov.test.kooweb.ru.access.log;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ /index.php;
}
# serve static files directly
location ~* \.(jpg|jpeg|gif|css|png|js|ico|map|coffee|svg)$ {
access_log off;
expires max;
}
location ~ /\.ht {
deny all;
}
location ~* \.php {
try_files $uri =404;
include common/php-fpm;
}
}
common/php fpm包含:
fastcgi_pass php-fpm;
include fastcgi_params;
fastcgi_split_path_info ^(.+?\.php)(/.*)?$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_param SERVER_ADMIN email@example.com;
fastcgi_param SERVER_SIGNATURE nginx/$nginx_version;
fastcgi_index index.php;
版本:
- Ubuntu版本16.04
- Nginx版本1.12.1
- Php 7.1版
/show5/
地址时[error]26452#26452:*275在stderr中发送的FastCGI:“无法打开主脚本:/show5/index.php(没有这样的文件或目录)”,同时从上游读取响应头,客户端:,服务器:,请求:“GET/show5/HTTP/1.1”,上游:fastcgi://unix:/run/php/php7.1-fpm.sock:,主机:“
/show5/index.html
地址时[error]26452#26452:*278在stderr中发送的FastCGI:“在从上游读取响应头时,对脚本'/show5/index.html'的访问被拒绝(请参阅security.limit_extensions)”,客户端:,服务器:,请求:“GET/show5/index.html HTTP/1.1”,上游:fastcgi://unix:/run/php/php7.1-fpm.sock:,主机:“
我不知道如何修复此问题。添加一个附加块
location / {
try_files $uri $uri/ =404;
}
或者,如果您只想从html文件中获得它,请按如下方式添加它
location ~* \.html {
try_files $uri $uri/ =404;
}
添加一个附加块
location / {
try_files $uri $uri/ =404;
}
或者,如果您只想从html文件中获得它,请按如下方式添加它
location ~* \.html {
try_files $uri $uri/ =404;
}
因此,很明显,即使在您不想匹配的情况下,您也在匹配
.php
位置块。我在这里看到了几件事:
index index.php index.html index.htm;
这些按外观顺序进行试验。所以nginx将尝试在/foo/index.html之前重写到/foo/index.php
我建议您将index.php移到该列表的后面
index index.html index.htm index.php;
在.php位置块中,这很奇怪:
location ~* \.php {
try_files $1 $uri $uri/ $uri/index.php =404;
include common/php-fpm;
}
考虑到location块已经输入了这个位置,因为它匹配了something.php
,您正在尝试一些奇怪的事情,比如/foo/bar.php/和/foo/bar.php/index.php,但没有明显的原因。我建议将其简化为:
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
try_files $uri =404;
include common/php-fpm;
}
因此,很明显,即使在您不想匹配的情况下,您也在匹配
.php
位置块。我在这里看到了几件事:
index index.php index.html index.htm;
这些按外观顺序进行试验。所以nginx将尝试在/foo/index.html之前重写到/foo/index.php
我建议您将index.php移到该列表的后面
index index.html index.htm index.php;
在.php位置块中,这很奇怪:
location ~* \.php {
try_files $1 $uri $uri/ $uri/index.php =404;
include common/php-fpm;
}
考虑到location块已经输入了这个位置,因为它匹配了something.php
,您正在尝试一些奇怪的事情,比如/foo/bar.php/和/foo/bar.php/index.php,但没有明显的原因。我建议将其简化为:
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
try_files $uri =404;
include common/php-fpm;
}
两种方法都没有任何变化,我仍然有403错误。我能提供其他信息吗?当然,每次我都会重启
sudo服务nginx
。你是如何尝试访问该文件的?在您的问题中发布nginx错误日志谢谢。我已将此信息添加到问题中。两种方式都没有任何更改,我仍然有403错误。我能提供其他信息吗?当然,每次我都会重启sudo服务nginx
。你是如何尝试访问该文件的?在您的问题中发布nginx错误日志谢谢。我已将此信息添加到问题中。有什么共同点/php fpm?@gview我已使用common/php fpm
data编辑了问题,在@gview建议期间也编辑了vhost,但nginx error.log中的错误对于这两种情况都是相同的。您的配置中还有其他服务器块吗?@gview,谢谢!!另一个配置中确实存在错误。但是你的回答也很有用,谢谢。有什么共同点/php fpm?@gview我已经用common/php fpm
data编辑了这个问题,也在@gview建议期间编辑了vhost,但是nginx error.log中的错误对于这两种情况都是一样的。你的配置中还有其他服务器块吗?@gview,谢谢!!另一个配置中确实存在错误。但是你的回答也很有用,谢谢。它看起来很合乎逻辑,但没有结果:(错误是一样的。我在解决了主要问题后编辑了我的虚拟主机,谢谢。它看起来很合乎逻辑,但没有结果:(错误是一样的。我在解决了主要问题后编辑了我的虚拟主机,谢谢