Nginx错误:FastCGI在stderr中发送:"主脚本未知",同时从上游读取响应标头..."



我有一个yii2高级模板应用程序,运行在带有nginx和php8.1的centos9上。设置vhost配置如下:

server {
listen 80;
server_name mydomain.com;
root /home/lamtab/xp-app-main/app/appadmin/web;
index index.php index.html index.htm index.nginx-debian.html;
access_log "/var/log/nginx/mydomain.com.access.log";
error_log "/var/log/nginx/mydomain.com.error.log";
location / {
try_files $uri /index.php$is_args$args;
}
location ~* .php$ {
# With php-fpm unix sockets
fastcgi_pass unix:/run/php-fpm/www.sock;
include         fastcgi_params;
fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
}
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
fastcgi_connect_timeout 90;
fastcgi_send_timeout 90;
fastcgi_read_timeout 90;
}

域的错误日志报告

在stderr中发送的FastCGI:";初级脚本未知";从上游读取响应标头时">

nginx的错误日志报告

index.php";失败(13:权限被拒绝(

有线索吗?

在我的情况下,我白白浪费了几个小时,结果我不得不在ubuntu 22.04中重新启动php8.1-fpm服务。试试看,也许会有帮助。我的conf文件看起来像这个

server {
listen   80 default_server;
root /home/user/your_project/public/;
index index.php index.html index.htm;
access_log /home/user/your_project/nginx-access.log;
error_log /home/user/your_project/nginx-error.log;
server_name localhost;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ .php$ {
try_files $uri index.php =404;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

最新更新