简体   繁体   English

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

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

I'm a student just learning about nginx so please bear with me. 我是一名刚开始学习nginx的学生,所以请多多包涵。 I've just set up a LEMP stack and installed WordPress by following these guides: https://www.linode.com/docs/websites/cms/how-to-install-and-configure-wordpress https://www.linode.com/docs/websites/lemp/lemp-server-on-centos-7-with-fastcgi 我刚刚建立了雷电电磁脉冲堆和WordPress安装按下列指南: https://www.linode.com/docs/websites/cms/how-to-install-and-configure-wordpress 的https:// WWW。 linode.com/docs/websites/lemp/lemp-server-on-centos-7-with-fastcgi

However, when I access my domain where my index should be, I just get a popup to download my index.php. 但是,当我访问应该包含索引的域时,只会弹出一个窗口来下载index.php。 As far as the guides say, everything in my configurations is correct and I've tried making some changes to no avail. 就指南而言,我配置中的所有内容都是正确的,并且我尝试进行一些更改都无济于事。 Here are my configs: 这是我的配置:

tburg.io.conf: 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: 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 {
    }
}
}

From what I've read, it seems like maybe nginx isn't using fastcgi to parse PHP the way it's supposed to? 从我阅读的内容来看,似乎nginx并未使用fastcgi解析PHP的方式? However, none of the previous iterations of this question seem to fit the way I've got nginx configured, but it's unclear what I'm doing wrong. 但是,此问题的先前迭代似乎都不适合我配置nginx的方式,但尚不清楚我在做什么错。 Thanks for your help! 谢谢你的帮助!

A friend helped me get this fixed. 一个朋友帮我解决了这个问题。 I'll be posting a guide on setting this up properly on the blog I was trying to set up when I encountered this issue, and will post it here when I finish. 我将在遇到此问题时在尝试设置的博客上发布有关正确设置此设置的指南,完成后将在此处发布。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM