PHP文件下载页面加载而不是执行 – NGINX

我已经在根目录中build立了一个与我们的实际域一起的子域。 在根目录下的两个文件夹如下所示:

domain.com
sub.domain.com

当去到域名(已经存在)事情工作正常。 当去sub.domain.com(这是一个WordPress的安装) index.php文件只是下载和页面不加载或执行。

在我的etc/nginx/sites-available/sub.domain.com.conf我有:

 server { listen 80; root /var/www/sub.domain.com; index index.php index.html index.htm; server_name sub.domain.com; location / { try_files $uri $uri/ =404; } } 

我记得重新启动nginx服务器,但是,我们使用php-fpm,所以我不确定这是否可能是相关的。

它必须与PHP相关,因为当replace基本index.html文件的wordpress安装时,页面按预期加载。 有谁知道什么可能会导致这种行为?

我通过将以下内容添加到我的configuration中解决了这个问题:

 location ~ \.php$ { fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }