Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
NGINX/PHP下载而不是执行_Php_Nginx_Fastcgi - Fatal编程技术网

NGINX/PHP下载而不是执行

NGINX/PHP下载而不是执行,php,nginx,fastcgi,Php,Nginx,Fastcgi,我有一个NGINX服务器,上面运行着fastcgi/PHP。我需要向它添加userdirs,但我无法让PHP执行这些文件——它只是问我是否要下载它。它在没有userdir的情况下也可以工作(例如,它可以在physibots.info/hugs.php上工作,但不能在physibots.info/~kisses/hugs.php上工作) 配置: server { listen 80; server_name physibots.info; access_log

我有一个NGINX服务器,上面运行着fastcgi/PHP。我需要向它添加userdirs,但我无法让PHP执行这些文件——它只是问我是否要下载它。它在没有userdir的情况下也可以工作(例如,它可以在physibots.info/hugs.php上工作,但不能在physibots.info/~kisses/hugs.php上工作)

配置:

server {
    listen      80;
    server_name physibots.info;
    access_log  /home/virtual/physibots.info/logs/access.log;

    root /home/virtual/physibots.info/public_html;

    location ~ ^/~(.+?)(/.*)?\.php$ {
        fastcgi_param SCRIPT_FILENAME /home/$1/public_html$fastcgi_script_name;
        fastcgi_pass unix:/tmp/php.socket;
    }

    location ~ ^/~(.+?)(/.*)?$ {
        alias /home/$1/public_html$2;
        autoindex on;
    }

    location ~ \.php$ {
        try_files $uri /error.html/$uri?null;
        fastcgi_pass unix:/tmp/php.socket;
    }
}

我以前在另一台服务器上遇到过类似的问题。我的问题是脚本containerd
尝试将这一行添加到php位置块:

fastcgi_param  REDIRECT_STATUS    200;

顺便说一句-你检查过php.socket是否确实存在吗?

结果是它链接到了/home/foo/public\u html/~foo。因此,从/home/foo/public_html/~foo返回到/home/foo/public_html的循环符号链接非常有用。谢谢你的帮助

不,此脚本使用
结尾。注意:我也尝试过在没有第一个位置块的情况下使用它,在第二个位置块中使用“fastcgi_param”行,并且完全没有,它们都具有相同的效果。它位于服务器范围的conf文件中。而且,正如我所说,它非常适用于主机名明确声明的站点和根域。对于命中
physibots.info/~kisses/hugs.php
的请求,错误日志显示了什么?只是一个猜测,但我认为这可能是您传递文件路径和脚本名的方式有问题。它没有显示有关请求的文件的任何信息。错误日志中唯一的消息是关于缺少favicon的消息。此外,根据PHP.ini中的错误日志指令,PHP在系统日志中没有报告任何内容。您使用的是PHP fpm吗?如果是这样,请确保在
php fpm.conf