为什么Nginx PHP Unit会忽略此配置文件中的root参数?

为什么Nginx PHP Unit会忽略此配置文件中的root参数?

我正在尝试将example.com多站点 WordPress 安装移至其单独的 WordPress 安装文件夹。我已经设置了一个单独的数据库,并wp-config.php为新的 WordPress 安装创建了一个新文件,其中包含启动新安装所需的信息。问题是,当我将 Nginx 配置文件中的参数root从旧的多站点安装文件夹切换到新的文件夹时,Nginx 仍会加载旧网站。

/etc/nginx/sites-available/example.com.conf

server {
    listen      80;
    listen      [::]:80;
    server_name example.com;
    root        /var/www/wordpress_exanoke/; # <-- this was changed to point to
                                               #     the new single site installation
                                               #     the old multisite installation
                                               #     folder is /var/www/wordpress

    if ($scheme = "http") {
        rewrite ^ https://$server_name$request_uri? permanent;
    }

    location / {
        try_files $uri @index_php;
    }

    location @index_php {
        proxy_pass       http://127.0.0.1:8090;
        proxy_set_header Host $host;
    }

    location /wp-admin {
        index index.php;
    }

    location ~* .php$ {
        try_files        $uri =404;
        proxy_pass       http://127.0.0.1:8091;
        proxy_set_header Host $host;
    }

    listen 443 ssl; # managed by Certbot
    listen [::]:443 ssl; #ipv6only=on; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/example.com/chained.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.com/domain.key; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

    ssl_client_certificate /etc/nginx/certs/cloudflare.crt;
    ssl_verify_client on;
}

答案1

事实证明,您正在使用 NGINX Unit 来提供 PHP 代码。在这种情况下,您还需要更改提供给 unit 的配置文件中的文档根目录,然后重新提交 API 调用以重新加载新配置。

答案2

您重启了nginx服务器吗?

nginx需要重新启动才能加载新配置。

使用命令sudo nginx -t测试您的配置是否正确。

sudo systemctl restart nginx重新启动。

相关内容