Yaf 在 Nginx 中的配置

Yaf 在 Nginx 下的配置


1、配置样例(Nginx v1.16.1)

server{
listen 80;
server_name 22.local;
root /usr/share/nginx/YfuncT2;
index index.php index.html;
if (!-e $request_filename) {
rewrite ^/(.*) /index.php?$1 last;
}
location / {
if ($request_filename ~* ^.*?.(txt)) {
add_header Content-Disposition "attachment;";
}
try_files $uri $uri/ =404;
}
location ~ .*\.php$ {
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}
location ~ /\.ht {
deny all;
}
}

2、错误记录

2.1 File not found.

Nginx error: File not found.

通过 /var/log/nginx/error.log 中的日志看到的更详细错误是:

2021/01/23 16:31:47 [error] 15368#0: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: t2.local, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "t2.local"

解决方案

  • 检查 fastcgi_param 的参数值
    正确的应为 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  • 检查文件权限 (上文对应 /usr/share/nginx/YfuncT2
    所有者应为 nginx 运行用户,并具备执行权限
  • 目录路径确认。root 的目录应为项目根目录
posted @   Hi_埃里克  阅读(783)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
点击右上角即可分享
微信分享提示