• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

Plesk 11.5 Linux - PHP-FPM and NGINX - Index.html error

You're not likely to get much help on 11.5 yet as it's not in public release yet. Submit a bug report instead...
 
When i activate the PHP-FPM portion of a user's domain in Plesk 11.5, NGINX continues to look for "index.html" at the end of every url. For example, www.mydomain.com/blog/ would normally take me to my blog. Instead, Nginx is looking for www.mydomain.com/blog/index.html, which isn't there.

any help please?
You need to reconfigure your nginx index file priority. This should be located in the nginx configuration file. It does seem weird though, as it has not happened to me. Which version are you testing? I've been testing 11.5 since the .24 version and so far nginx processes index.php fine on my end with fpm from remi.
 
Hi KonstantinosS,
Thanks for getting back to me.

I know what you're referring to with the processing order. I have already made that change. There is an important distinction to note. I do not have any problems accessing / running PHP files. The errors specifically start to occur when trying to access a page within a WordPress site -- the index page of the WordPress sites have no problem loading. Again, www.mydomain.com loads fine, but www.mydomain.com/contact/ displays an NGINX error. There are many sites out there that have documented this issue. Here is a good example: http://www.cult-of-tech.net/2011/11/wordpress-on-nginx-on-dreamhost/.

I went back and looked at that article and noticed that there are a number of wordpress plugins that claim to be able to solve this issue. I might give one of them a try and report back.
 
Hi KonstantinosS,
Thanks for getting back to me.

I know what you're referring to with the processing order. I have already made that change. There is an important distinction to note. I do not have any problems accessing / running PHP files. The errors specifically start to occur when trying to access a page within a WordPress site -- the index page of the WordPress sites have no problem loading. Again, www.mydomain.com loads fine, but www.mydomain.com/contact/ displays an NGINX error. There are many sites out there that have documented this issue. Here is a good example: http://www.cult-of-tech.net/2011/11/wordpress-on-nginx-on-dreamhost/.

I went back and looked at that article and noticed that there are a number of wordpress plugins that claim to be able to solve this issue. I might give one of them a try and report back.
Hi VinnyT,

I'm afraid that I've never worked with Wordpress, so I can't help you much. I would suggest checking those rewrite rules or disabling them completely until you solve the issue in a demo
 
OK, good news. It turns out that domains that are migrated from previous version of Plesk (11.x) have this issue. Newly created domains do NOT have this issue; they re-write properly with WordPress. That pointed me to the last_nginx.conf and last_httpd.conf files located within /var/www/system/domain/conf. The two domains have DIFFERENT last_nginx.conf files. I tried deleting the files and having the server regenerate them using HTTPDMNG, but they were recreated with the original information. Does anyone have any idea what might be causing the difference in these files? Where are the templates stored? How could they be different per domain?

Thanks!
 
OK, good news. It turns out that domains that are migrated from previous version of Plesk (11.x) have this issue. Newly created domains do NOT have this issue; they re-write properly with WordPress. That pointed me to the last_nginx.conf and last_httpd.conf files located within /var/www/system/domain/conf. The two domains have DIFFERENT last_nginx.conf files. I tried deleting the files and having the server regenerate them using HTTPDMNG, but they were recreated with the original information. Does anyone have any idea what might be causing the difference in these files? Where are the templates stored? How could they be different per domain?

Thanks!
No idea about the issue, you could however copy the contents of the conf file and see what happens. In any case, keep a backup!!!! And do a bug report, that may help them sort things out. Also, if it's not a production server, you could delete the domain and recreate it.
 
OK, good news. It turns out that domains that are migrated from previous version of Plesk (11.x) have this issue. Newly created domains do NOT have this issue; they re-write properly with WordPress. That pointed me to the last_nginx.conf and last_httpd.conf files located within /var/www/system/domain/conf. The two domains have DIFFERENT last_nginx.conf files. I tried deleting the files and having the server regenerate them using HTTPDMNG, but they were recreated with the original information. Does anyone have any idea what might be causing the difference in these files? Where are the templates stored? How could they be different per domain?

Thanks!

Hello VinceT,

In case you have not solved the problem by your selves yet. Now some more helpful remarks from Greece. B-)

In your Plesk go to the domain in question.
Home>
Subscriptions>
singersretreat.com> ( my test domain)
Websites & Domains>
Web Server Settings>


There you look for the section nginx settings and tick the two boxes named
Serve static files directly by nginx
Process PHP by nginx


This does insert into the nginx config file
/var/www/vhosts/system/singersretreat.com/conf/last_nginx.conf
amongst other stuff the following.....
location ~ /$ {
index index.html index.cgi index.pl index.php index.xhtml index.htm index.shtml;
}


Maybe you are faster in editing in the console with vi rather then using the GUI.

As a picture says more then 1000 Words I also attache a screenshoot for you to guide you to solve the issue.

kind regards from a greek geekgeeks2rent_92_20130702-184215.jpg
 
I tried this workaround with 11.5.30 #3 but I still get the nginx 404 errors when using permalinks. The WP site works fine with php-fpm and regular links. I noticed that ONLY with php-fpm enabled, wordpress doesnt offer me the pretty permalink option in settings unless I install the WP nginx plugin 2.7.2. I guess it tells WP that mod_rewrite is available. It works fine then with the index.php written into the URLs. What I don't understand is why pretty permalinks work with nginx without the php-fpm option enabled but not with it being on. Only with php being handled by nginx via php-fpm the rewriting seems to fail resulting in the 404 error. Any ideas anybody?
 
I tried this workaround with 11.5.30 #3 but I still get the nginx 404 errors when using permalinks. The WP site works fine with php-fpm and regular links. I noticed that ONLY with php-fpm enabled, wordpress doesnt offer me the pretty permalink option in settings unless I install the WP nginx plugin 2.7.2. I guess it tells WP that mod_rewrite is available. It works fine then with the index.php written into the URLs. What I don't understand is why pretty permalinks work with nginx without the php-fpm option enabled but not with it being on. Only with php being handled by nginx via php-fpm the rewriting seems to fail resulting in the 404 error. Any ideas anybody?

Hi Timer -- If you want to repost your question on my site as a comment, I'll be happy to look at it for you. Please use the link in my previous post above.
 
Thanks. I would if I could but somehow I can't seem to figure out how to do it. The "leave a comment" function seems to be greyed out? Or am I just blind?
 
What I don't understand is why pretty permalinks work with nginx without the php-fpm option enabled but not with it being on. Only with php being handled by nginx via php-fpm the rewriting seems to fail resulting in the 404 error. Any ideas anybody?

If your only question is "why", then I'll save you the trouble of reposting it. The answer is - just because with php-fpm enabled rewriting is handled by nginx or php and in nginx reverse proxy mode it is handled by Apache.
 
If your only question is "why", then I'll save you the trouble of reposting it. The answer is - just because with php-fpm enabled rewriting is handled by nginx or php and in nginx reverse proxy mode it is handled by Apache.

Ah, okay. Thank you. Well yes, that would bring up the question why it fails when handled by nginx/php and how/where it is configured. With Apache, WP explicitly asks to change the .htaccess to put in the rewriting rules for permalinks. Okay, htaccess is for apache only. I'm wondering if it is a general problem that WP permalinks like "www.sitename.com/mypage/" instead of "www.sitename.com/index.php/mypage" fail with nginx and php-fpm enabled, or if it is a specific problem with my site. Once more to be clear, all other WP stuff works fine even with nginx and php-fpm. Just not those pretty permalinks.
 
It is in fact a general problem of using php-fpm + nginx instead of Apache + whatever-php for popular applications, since they usually rely on rewriting via .htaccess configuration. .htaccess or similar mechanism is not available for nginx (for performance reasons, AFAIK), hence applications should provide alternative installation instructions under nginx. IIRC, Wordpress does indeed provide such instructions.

BTW, it says there (see link above):

WordPress includes checks for Apache mod_rewrite before enabling permalinks. This check will fail on nginx, which can leave 'index.php' in the permalink structure.

To force WordPress to enable permalinks completely, add the following to a plugin ...
 
As I said before, I did have the nginx helper plugin installed into WP which somehow tells WP that mod_rewrite is available. But what good does that do if the rewriting itself does not happen correctly? I thought the fix from VinnyT mentioned above would exactly take care of that. Apparently, I doesn't for me and I can't figure out why.
 
You need to reconfigure your nginx index file priority. This should be located in the nginx configuration file. It does seem weird though, as it has not happened to me. Which version are you testing? I've been testing 11.5 since the .24 version and so far nginx processes index.php fine on my end with fpm from remi.

sorry about that. please try not (and tanks for pointing that out) :)
 
As weird as that might sound, REMOVING the following part from the nginx conf solved the problem:

location ~ /$ {
index index.html index.cgi index.pl index.php index.xhtml index.htm index.shtml;
}
 
@timber

if I remove the location directive

location ~ /$ {
index index.php index.cgi index.pl index.html index.xhtml index.htm index.shtml;
}

from /etc/nginx/plesk.conf.d/vhosts/YOURDOMAIN.conf

And Add it to

/var/www/vhosts/system/YOURDOMAIN/conf/vhost_nginx.conf

location ~ /$ {
index index.php index.cgi index.pl index.html index.xhtml index.htm index.shtml;
try_files $uri
$uri/ /index.php?$args;
}

it works perfectly.
However PLESK clearly states in /etc/nginx/plesk.conf.d/vhosts/YOURDOMAIN.conf
#DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
#SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.

How do we totally remove / stop

location ~ /$ {
index index.php index.cgi index.pl index.html index.xhtml index.htm index.shtml;
}

from been rewritten?
 
You cannot modify files in plesk.conf.d - they will be rewritten on the next web server configuration re-generation. You can technically workaround this issue by using custom web server templates, but it will likely lead to issues in future upgrades.

However, after reading nginx documentation solution seems really obvious. I cannot fathom why nobody came up with it yet.

Here it is (should be placed in custom nginx vhost configuration, i.e., either in /var/www/vhosts/system/domain.tld/conf/vhost_nginx.conf or via Panel UI):

Code:
[FONT=Lucida Console]location ^~ /wordpress/ {
        index index.html index.php;
        try_files $uri $uri/ /wordpress/index.php?$args;

        # This location should be exact copy of the one from /etc/nginx/plesk.conf.d/vhosts/domain.tld.conf
        location ~ ^/(.*\.(ac3|avi|bmp|bz2|css|cue|dat|doc|docx|dts|exe|flv|gif|gz|htm|html|ico|img|iso|jpeg|jpg|js|mkv|mp3|mp4|mpeg|mpg|ogg|pdf|png|ppt|pptx|qt|rar|rm|swf|tar|tgz|txt|wav|xls|xlsx|zip))$ {
                try_files $uri @fallback;
        }
        # This location should be exact copy of the one from /etc/nginx/plesk.conf.d/vhosts/domain.tld.conf
        location ~ \.php(/.*)?$ {
                fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
                fastcgi_param PATH_INFO $fastcgi_path_info;
                fastcgi_pass "unix:/var/www/vhosts/system/domain.tld/php-fpm.sock";
                include /etc/nginx/fastcgi.conf;
        }
}
[/FONT]

Of course, this assumes that Wordpress is installed in domain.tld/wordpress/.
 
Last edited:
Back
Top