Nginx phpmyadmin redirecting to / instead of /phpmyadmin upon login

Even though the author has solved his problem reinstalling phpMyAdmin, nginx needs to be properly configurated to handle the redirect upon login correctly.

After days smashing my head on the keyboard I finally found the real solution and I'm sharing here as this thread still have high priority on google search.

As stated on the link : http://www.samundra.com.np/use-phpmyadmin-with-nginx-and-php7/1374

To solve the problem, you should add the following block of code to your nginx default site-available, you will access it with :

sudo nano /etc/nginx/sites-available/default

Place this block in server block:

# Phpmyadmin Configurations
    location /phpmyadmin {
       root /usr/share/;
       index index.php index.html index.htm;
       location ~ ^/phpmyadmin/(.+\.php)$ {
               try_files $uri =404;
               root /usr/share/;
               #fastcgi_pass 127.0.0.1:9000;
               #fastcgi_param HTTPS on; # <-- add this line
               fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
               fastcgi_index index.php;
               fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
               include fastcgi_params;
       }
       location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
               root /usr/share/;
       }
   }

   # Dealing with the uppercased letters
   location /phpMyAdmin {
       rewrite ^/* /phpmyadmin last;
   }

I hope this helps someone one day...


This problem is caused by the common configuration of cgi.fix_pathinfo = 0 that disables the current path for PHP-FPM. One quick solution is to change cgi.fix_pathinfo back to 1, or set the path parameters on the virtual server block of nginx.


You're problem seems to be similar to this: https://stackoverflow.com/questions/1011101/nginx-location-directive-doesnt-seem-to-be-working-am-i-missing-something

If by reading that and changing you're config you still have problems please do tell!