doubiao7267 2014-06-23 09:44
浏览 82
已采纳

使用套接字将PHP请求传递给PHP-FPM

I was trying to set up linux-dash on my server running gunicorn with nginx as reverse proxy. I tried setting up the configuration file as suggested here. Every time I try to open one of the php scripts in the browser, it throws a "404 not found" error. As far as I understand the following block in the configuration file is responsible for it.

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;
}

Can someone help me understand what the condition in the if block actually means? And where am I going wrong?
As far as the location directive is concerned, what I understand from it is that it tries to find if a php script needs to be executed and accordingly splits the path to the script and somehow using fastcgi runs that script on the browser. Please correct me if I am wrong and provide a better understanding of what it means.

  • 写回答

1条回答 默认 最新

  • dongxian5735 2014-06-23 09:50
    关注

    It is checking for the existence of file. Ensure the path exists. You should try to use try_files instead.

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

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 matlab计算中误差
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊