Why is the Nginx PHP Unit ignoring the root parameter in this configuration file?

rraallvv asked:

I’m trying to move mywebsite.com from a multisite WordPress installation into its separate WordPress installation folder. I’ve already setup a separate database and created a new file wp-config.php for the new WordPress installation with the information needed to start the new installation. The problem is that when I switch the parameter root in the Nginx configuration file from the old multisite installation folder to the new one, the old website is still loaded by Nginx.

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

server {
    listen      80;
    listen      [::]:80;
    server_name mywebsite.com;
    root        /var/www/wordpress_mywebsite/; # <-- 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/mywebsite.com/chained.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/mywebsite.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;
}

My answer:


It turned out that you are using NGINX Unit to serve your PHP code. In that case you also need to change the document root in the configuration file that you provide to unit, and resubmit the API call to reload the new configuration.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.