我有一个 yii2 高级模板应用程序在 centos 9 上运行,带有 nginx 和 php 8.1。设置虚拟主机配置如下:
server {
lis ten 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;
}
域的错误日志报告
FastCGI 在 stderr 中发送:“主脚本未知”,同时从上游读取响应标头...”
以及nginx的错误日志报告
index.php”失败(13:权限被拒绝)
有什么线索吗?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
就我而言,我白白浪费了几个小时,结果我只需要在 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; } }