• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • 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.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

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

Hi Nikolay,

I tried your solution but I get an error message saying: "Invalid nginx configuration: nginx: [emerg] duplicate location "/" in /var/www/vhosts/system/DOMAIN.TLD/conf/vhost_nginx.conf:1 nginx: configuration file /etc/nginx/nginx.conf test failed"

That's because I don't have my WP in "/wordpress/" but "/".

I understand about the configuration being rewritten but once I got it working, there was no need to regenerate the configs and they won't be overwritten automatically.
 
I tried your solution but I get an error message saying: "Invalid nginx configuration: nginx: [emerg] duplicate location "/" in /var/www/vhosts/system/DOMAIN.TLD/conf/vhost_nginx.conf:1 nginx: configuration file /etc/nginx/nginx.conf test failed"

That's because I don't have my WP in "/wordpress/" but "/".

Yes. I doubt you can currently implement custom configuration without custom web server templates or editing Plesk configs manually if your permalinks do not have distinctive prefix (or prefixes).

I understand about the configuration being rewritten but once I got it working, there was no need to regenerate the configs and they won't be overwritten automatically.

The problem with this approach is that you won't immediately notice that configuration was re-generated.


Since everybody in this thread is interested in the so-called "pretty" permalinks, maybe somebody will enlighten me, why are they so important?

As I see it, permalinks serve two purposes:
1) be permanent - check;
2) be human readable - check (even if there is index.php in permalink, it doesn't make it less human readable).
 
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/.


Hello,

I have a question when you say: # This location should be exact copy of the one from /etc/nginx/plesk.conf.d/vhosts/domain.tld.conf

Is to put where? Here: location ~ /var/www/vhosts/domain.com/folder \.php(/.*)?$

?
 
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/.


Hello,

I have a question when you say: # This location should be exact copy of the one from /etc/nginx/plesk.conf.d/vhosts/domain.tld.conf

Is to put where? Here: location ~ /var/www/vhosts/domain.com/folder \.php(/.*)?$

?
 
I'm not sure I got your question, PedroV. But this means "look into this file and copy similar configuration sections (starting with location and ending with }) from there (if you have them)". Obviously path to file may differ depending on OS.
 
I'm not sure I got your question, PedroV. But this means "look into this file and copy similar configuration sections (starting with location and ending with }) from there (if you have them)". Obviously path to file may differ depending on OS.

I have CentOS 6.4 and my doubt is where I put the path to location. Imagine that my location is: /var/www/vhosts/domain.com.

When you say

#This location should be exact copy of the one from /etc/nginx/plesk.conf.d/vhosts/domain.tld.conf
location ~ \.php(/.*)?$ {

I put as: location ~ /var/www/vhosts/domain.com\.php(/.*)?$ {

Is correct?

Thank you
 
I'm not sure how I can make this even more clear.

OK, since you're using CentOS, do following:

1) Determine your domain name (assuming it's the main domain on subscription) and subdirectory in httpdocs where you have Wordpress installed (installing directly into httpdocs is not supported by this manual). In all further steps please replace domain.tld for your domain name and wordpress for your installation directory.

2) Add custom nginx configuration posted above on your domain replacing all domain.tld and wordpress substrings as described in step (1).

3) If you're not doing this via UI, run # plesk sbin httpdmng --reconfigure-domain domain.tld

And viola - it works!
 
Have you tried the following additional nginx configuration?

if (!-e $request_filename){
rewrite ^(.*)$ /index.php break;
}

(without specifying location)
It is really simple and looks able to work.
 
Possible configuration without "if":

rewrite !\.(js|ico|gif|jpg|png|css|pdf|mov|mp3|eot|svg|ttf|woff|otf|txt)$ /index.php break;
rewrite /$ /index.php break;
 
@Eugene Kazakov

Thanks. That helped me. I have added a line to make Wordpress wp-admin accessible. Now it looks like this:

rewrite !\.(js|ico|gif|jpg|png|css|pdf|mov|mp3|eot|svg|ttf|woff|otf|txt)$ /index.php break;
rewrite /wp-admin/$ /wp-admin/index.php break;
rewrite /$ /index.php break;
 
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]
[/FONT].

Hello! This code worked for me but I have a problem.. I have a forum (vbulletin) installed on www.domain.tdl/forums/. If I access the home page (www.domain.tdl/forums/) or directly a page like: www.domain.tdl/forums/section-name/name-of-thread.html it works.. but if I try to access the section (www.domain.tdl/forums/section-name/) it doesn't work.
Anyone can help me with this?
 
Last edited:
@ AkaMaru:

You will need some rewrite rules like these ones:

rewrite ^/content?(.*) /content.php?$1 break;
rewrite ^/threads/ /showthread.php?$uri last;
rewrite ^/forum/images/(.*) /images/$1 last;
rewrite ^/forums/ /forumdisplay.php?$uri last;
rewrite ^/forums/(css|cron|index).php(.*) /$1.php$2 last;
rewrite ^/members/ /member.php?$uri last;
rewrite ^/blog(s*)/ /blog.php?$uri last;
rewrite ^/entries/ /entry.php?$uri last;
rewrite ^/content/ /content.php?$uri last;
rewrite ^/list/ /list.php?$uri last;
rewrite ^/widget/config/(.*) /widget.php?r=config/$uri last;

Some How-to's for rewrite rules can be found here: Plesk 11.5 Linux - PHP-FPM and NGINX - Index.html error
 
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/.

After researching deeply within many links in google, your solution finally solved my issues with wordpress subdirectory in plesk. Thank you very very much :)
 
Back
Top