The reason it doesn't work is because ...
At the server level, you have "root / var / www / root". Thus, each location block will use it, unless it is overridden. This is a good practice.
Then you redefined it in the location block βwpβ to β/ var / www / wordpressβ. However, the php location block still uses the default value.
Now, when you place a request on "/wp/folder_a/file_a.php", which is physically located in "/var/www/wordpress/folder_a/file_a.php", the request falls into the php location block and the root folder that is active for of this block, it searches for the file in "/var/www/root/folder_a/file_a.php". As a result, you get "404 not found."
You can change the server level root directive to "/ var / www / wordpress" and remove the override at the wp location. This will solve this problem, but php scripts under "/ var / www / root" will no longer work. Not sure what you have.
If you need to run php under "/ var / www / root" and "/ var / www / wordpress", you need to do this:
server { ... root /var/www/root; index index.php index.htm index.html; # Keep fastcgi directives together under location # so removed fastcgi_index # Put keepalive_timeout under 'http' section if possible location /wp/ { root /var/www/wordpress; # One appearance of 'index' under server block is sufficient location ~* \.php$ { try_files $uri =404; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; } } location ~* \.php$ { try_files $uri =404; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; } }
That is, in the wp location block, the php location duplication block is located. It inherits the root directive for wp.
To help save succes and facilitate editing, etc., you can put the fastcgi directives in a separate file and include it as needed.
So in /path/fastcgi.params you have:
fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000;
Now your conf could be:
server { ... root /var/www/root; ... location /wp/ { root /var/www/wordpress; location ~* \.php$ { try_files $uri =404; include /path/fastcgi.params; } } location ~* \.php$ { try_files $uri =404; include /path/fastcgi.params; } }
Thus, if you need to edit any fastcgi parameter, you will simply edit it in one place.
PS. Updating nginx will not solve the problem, since it is not a problem with the version, but the update anyway!