nginx保持下载index.php不执行

nginx保持下载index.php不执行,nginx,php-7,Nginx,Php 7,我正在用nginx和php7设置一个服务器 这里是我的配置: server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /var/www/home; index index.php index.html index.htm; server_name localhost; charset utf-8; location / {

我正在用nginx和php7设置一个服务器

这里是我的配置:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /var/www/home;
    index index.php index.html index.htm;

    server_name localhost;
    charset   utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php\$ {
        try_files \$uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)\$;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
        include fastcgi_params;
    }
}
但这会不断下载index.php,当我输入IP时,它会重定向到index.php-IP/index.php

更新: 将位置
location~\.php\${
更改为
location~\.php${
停止下载文件。 但是现在我得到了一个错误:

29861#29861: *1 FastCGI sent in stderr: "Unable to open primary script: \/var/www/home\/index.php (No such file or directory)" while reading response header from upstream, client: ..., server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "..."

在我的配置中,$uri之前没有。无论如何-问题可能出在fastcgi配置中。不是这样的。你的fastcgi/fpm配置如何?检查我的更新,可能是问题。删除
\$uri
并改为放置
$uri
。与
fastcgi参数脚本文件名
相同:删除我的$uri之前没有\配置。无论如何-问题可能在fastcgi配置中。不是这样的。fastcgi/fpm配置如何?检查我的更新,可能是问题。删除
\$uri
并放置
$uri
。与
fastcgi参数脚本文件名
相同:删除`\`