Symptoms
-
After setting PHP for a domain as FPM application served by nginx in Plesk at Domains > example.com > PHP Settings, only start page is loading in a web-browser. Other pages show "404 Not Found" error.
-
The domain is using rewrite rules, which are defined in the
.htaccess
file.
Cause
When PHP is running as FPM application served by nginx, PHP files are processed by nginx which does not use .htaccess
files like Apache does.
This issue has been addressed in Plesk Obsidian 18.0.34 where new WordPress installations work with PHP-FPM served by nginx.
Resolution
This issue has been addressed in Plesk Obsidian 18.0.34 where new WordPress installations work with PHP-FPM served by nginx.
For older WordPress installations, apply one of the following solutions:
-
Go to Domains > example.com > Hosting & DNS > Apache & nginx Settings.
-
Add the content below to the Additional nginx directives field:
if (!-e $request_filename) {
set $test P;
}
if ($uri !~ ^/(plesk-stat|webstat|webstat-ssl|ftpstat|anon_ftpstat|awstats-icon|external-nginx-static-location|status_phpfpm)) {
set $test "${test}C";
}
if ($test = PC) {
rewrite ^/(.*)$ /index.php?$1;
}
-
-
If this is a WordPress installation, which is located in a subdirectory (for example, "httpdocs/sub-dir") or this is a WordPress multisite network based on subdirectories, add the /sub-dir/ before /index.php?$1 so it will look like this:
rewrite ^/(.*)$ /sub-dir/index.php?$1;
Note: For WordPress multisite network based on subfolder, add the above rule for each subdirectory.
-
-
Connect to the Plesk server via SSH.
-
Create a directory for custom templates and copy default configuration templates there:
# mkdir -p /usr/local/psa/admin/conf/templates/custom/domain
# cp /usr/local/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php
Note: Any changes made in original configuration templates will be lost after an installation of Plesk micro-updates.
-
Open the file
/usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php
in any text editor (for example, with vi editor) and replace the section:-
on Plesk Onyx 17.5, 17.8:
<?php if ($VAR->domain->physicalHosting->directoryIndex): ?>
location ~ /$ {
index <?=$VAR->quote($VAR->domain->physicalHosting->directoryIndex)?>;
}
<?php endif ?> -
on Plesk Obsidian:
<?php if ($VAR->domain->physicalHosting->directoryIndex && !$VAR->domain->physicalHosting->proxySettings['nginxProxyMode']): ?>
location ~ /$ {
index <?=$VAR->quote($VAR->domain->physicalHosting->directoryIndex)?>;
}
<?php endif ?>
with the following content:
location ~ / {
index index.php index.cgi index.pl index.html index.xhtml index.htm index.shtml;
try_files $uri $uri/ /index.php$is_args$args;
} -
-
Regenerate web-server configuration files:
# plesk repair web -y