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

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

报告相同问题?

悬赏问题

  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启