Nginx appends the path given in the URI

Solution 1:

I'm trying to configure phpMyAdmin so I've set the flowing location in Nginx however it apends the "pma" to the root directory

Because it is... the way root directive works.

If you want to use root directive inside the location block, you must specify an URI same as the directory name and strip it off from the root, something like this:

    location /phpmyadmin {
        root /usr/share/;
        try_files $uri $uri/ /index.php;

        location ~ ^/phpmyadmin(.+\.php)$ {
            root /usr/share/;
            fastcgi_pass 127.0.0.1:9000;
            include fastcgi.conf;
            fastcgi_intercept_errors        on;
        }
    }

If you want to keep URI simpler, use alias directive instead:

    location /pma {
        alias /usr/share/phpmyadmin/;
        try_files $uri $uri/ /index.php;

        location ~ ^/pma(.+\.php)$ {
            alias /usr/share/phpmyadmin$1;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_param SCRIPT_FILENAME /usr/share/phpmyadmin$1;
            include fastcgi_params;
            fastcgi_intercept_errors        on;
        }
    }