【问题标题】:Pass PHP requests on to PHP-FPM using sockets使用套接字将 PHP 请求传递到 PHP-FPM
【发布时间】:2014-06-23 17:50:03
【问题描述】:

我试图在运行 gunicorn 的服务器上设置 linux-dash,并使用 nginx 作为反向代理。我尝试按照here 的建议设置配置文件。 每次我尝试在浏览器中打开其中一个 php 脚本时,都会引发“404 not found”错误。据我了解,配置文件中的以下块负责它。

location ~ \.php(/|$) {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    fastcgi_pass unix:/run/php5-fpm.sock;
    #fastcgi_pass localhost:9000; # using TCP/IP stack
    if (!-f $document_root$fastcgi_script_name) {
        return 404;
    }
    try_files $uri $uri/ /index.php?$args;
    include fastcgi_params;
}

有人可以帮我理解 if 块中的条件的实际含义吗?我哪里错了?
就 location 指令而言,我从中了解到的是,它会尝试查找是否需要执行 php 脚本并相应地拆分脚本的路径,并以某种方式使用 fastcgi 在浏览器上运行该脚本。如果我错了,请纠正我并更好地理解它的含义。

【问题讨论】:

    标签: nginx fastcgi php


    【解决方案1】:

    它正在检查文件是否存在。确保路径存在。您应该尝试改用try_files

    http://wiki.nginx.org/Pitfalls#Check_IF_File_Exists

    http://wiki.nginx.org/NginxHttpCoreModule#try_files

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-09
      • 2018-04-13
      • 1970-01-01
      • 2016-02-25
      • 1970-01-01
      • 2014-08-11
      • 2016-06-30
      • 1970-01-01
      相关资源
      最近更新 更多