.php 文件被下载而不是显示

.php files are downloaded instead of displayed

首先,是的,有很多这样的问题,但 none 的解决方案对我有用。 我有一个类似的服务器可以比较,我查看了配置,它似乎可以工作,而这个新设置没有。

我已经尝试修改配置,但没有任何优势。

我的nginx.conf:

[default content]
#I just appended this line:
client_max_body_size 10M;

我的虚拟主机文件:

server {
    listen 80;
    listen [::]:80;

#    root /var/www/mywebsite.com/public_html;

 #   index index.html;

    server_name mywebsite.com www.mywebsite.com;

   # access_log /var/log/nginx/mywebsite.com.access.log;
   # error_log /var/log/nginx/mywebsite.com.error.log;
    include snippets/letsencrypt.conf;
    return 301 https://$host$request_uri;
   # location / {
   #     try_files $uri $uri/ =404;
    }
server {
    listen 443 ssl http2;
    server_name www.mywebsite.com;

    ssl_certificate /etc/letsencrypt/live/mywebsite.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mywebsite.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/mywebsite.com/chain.pem;
    include snippets/ssl.conf;
    include snippets/letsencrypt.conf;

    return 301 https://mywebsite.com$request_uri;
}
server {
    listen 443 ssl http2;
    server_name mywebsite.com;

    ssl_certificate /etc/letsencrypt/live/mywebsite.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mywebsite.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/mywebsite.com/chain.pem;
    include snippets/ssl.conf;
    include snippets/letsencrypt.conf;


    root /var/www/mywebsite.com/public_html;
    index index.php;
    # . . . other code

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
 }

#location / {
#        try_files $uri $uri/ /index.php?$args;
#}
#location ~ \.php$ {
#        fastcgi_split_path_info ^(/wordpress)(/.*)$;
#}

include snippets/phpmyadmin.conf;
}

P.S 是的,我正在使用 WordPress。

所以这似乎只是一个缓存问题,所以我不得不等待,然后它就起作用了。配置没问题。案件结案。