nginx要求浏览器下载index.php,而不是正常服务


nginx asks browser to download index.php instead of serving normally

我是一个刚刚学习nginx的学生,请耐心等待。我刚刚建立了一个LEMP堆栈,并按照以下指南安装了WordPress:https://www.linode.com/docs/websites/cms/how-to-install-and-configure-wordpresshttps://www.linode.com/docs/websites/lemp/lemp-server-on-centos-7-with-fastcgi

然而,当我访问我的域时,我的索引应该在哪里,我只会得到一个弹出窗口来下载我的index.php。就指南所说,我的配置中的一切都是正确的,我尝试过做一些更改,但没有成功。以下是我的配置:

tburg.io.conf:

server {
     listen 80;
     server_name www.tburg.io tburg.io;
     access_log /var/www/tburg.io/logs/access.log;
     error_log /var/www/tburg.io/logs/error.log;
     location / {
          root /var/www/tburg.io/public_html/;
          index index.php;
     }
}

nginx.conf:

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
    worker_connections 1024;
}
http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
access_log  /var/log/nginx/access.log  main;
sendfile            on;
tcp_nopush          on;
tcp_nodelay         on;
keepalive_timeout   65;
types_hash_max_size 2048;
include             /etc/nginx/mime.types;
default_type        application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  _;
    root         /usr/share/nginx/html;
    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;
    location / {
    }
    error_page 404 /404.html;
        location = /40x.html {
    }
    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}
}

从我读到的内容来看,nginx似乎没有按照它应该的方式使用fastcgi来解析PHP?然而,这个问题之前的迭代似乎都不符合我配置nginx的方式,但不清楚我做错了什么。谢谢你的帮助!

一个朋友帮我解决了这个问题。当我遇到这个问题时,我会在我试图设置的博客上发布一个正确设置指南,并在我完成后将其发布在这里。