NginX Ubuntu 20.04 PHP 7.4上wordpress/blog文件的404错误

NginX Ubuntu 20.04 PHP 7.4上wordpress/blog文件的404错误,php,nginx,ubuntu-20.04,Php,Nginx,Ubuntu 20.04,我在同一台服务器上的Django API驱动的站点根目录下运行VueJS系统 example.com是一个测试版 我想将wordpress加载到子文件夹中example.com/blog 我正在运行Nginx[没有Apache-并且没有安装Apache] 安装了PHP和MySQL并编辑了我们的服务器块。请参阅下面的代码 我在/blog中尝试访问的任何文件都会出现404个错误 https://example.com/blog/readme.html https://example.com/blo

我在同一台服务器上的Django API驱动的站点根目录下运行VueJS系统

example.com是一个测试版

我想将wordpress加载到子文件夹中example.com/blog

我正在运行Nginx[没有Apache-并且没有安装Apache]

安装了PHP和MySQL并编辑了我们的服务器块。请参阅下面的代码

我在/blog中尝试访问的任何文件都会出现404个错误

https://example.com/blog/readme.html 
https://example.com/blog/test.php 
https://example.com/blog/index.php 
https://example.com/blog/wp-admin/install.php
这是我们的服务器块代码 {IP屏蔽}

server {
    server_name example.com www.example.com 128.199.###.###;

    root /var/www/html/vue/example/dist;

    location = /favicon.ico { access_log off; log_not_found off; }

    location /static/ {
        alias /home/example/src;
    }

    location / {
        try_files $uri $uri/ /index.html /index.php;
    }

    location ^~ /rest-auth/ {
    include proxy_params;
    proxy_pass http://unix:/run/gunicorn.sock;
    }

    location ^~ /api/ {
    include proxy_params;
    proxy_pass http://unix:/run/gunicorn.sock;
    }

    location ~ /\.ht {
        deny all;
    }

    location ^~ /admin {
    include proxy_params;
    proxy_pass http://unix:/run/gunicorn.sock;
    }

    location ^~ /blog {
      alias /var/www/html;
      index index.php index.html index.htm;
      try_files $uri =404;
    }

# For security reasons, set php settings at root level.
# This prevents root level php files from showing as plain text.
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    }

    error_log  /var/log/nginx/example-error.log;
    access_log /var/log/nginx/example-access.log;

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}
server {
    if ($host = www.example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;
    server_name example.com www.example.com 128.199.###.###;
    return 404; # managed by Certbot

}



非常感谢您的帮助——我查阅了大量资源,尝试了很多方法,但都没有成功——谢谢。

chrome下载问题掩盖了代码中的一个简单错误路径!Firefox展示了一个简单的404,很容易调试

最终的解决方案是为博客添加此位置:

location /blog {
          alias /var/www/html/blog;
          try_files $uri $uri/ @blog;

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

     location @blog {
         rewrite /blog/(.*)$ /blog/index.php?/$1 last;
     }

这有帮助吗:或者?谢谢@Martin你太棒了——谢谢这些——我没有登录Firefox——只是在chrome中测试——在Firefox中我得到了一个404所以,至少情况看起来好了一点——似乎我现在在某个地方遇到了链接/路径问题——不用担心!问一个关于堆栈溢出的新问题是一个中心原则,首先检查是否还没有问过类似的问题,否则你的问题可能会被重复关闭。我更新了这个问题以反映当前的问题,因为chrome屏蔽了@Martin--firefox显示了一个404错误,用于/blog链接