I can't open phpMyAdmin, get error 301 or 500

Solution 1:

There were multiple causes preventing me from logging in to phpMyAdmin:

mbstring

The error 500 generates a message PHP Fatal error: Call to undefined function mb_detect_encoding() in /usr/share/php/gettext/gettext.inc on line 177 on the file /var/log/php-fpm/www-error.log. According to a comment on http://www.php.net/manual/en/mbstring.installation.php I tried to install the php-mbstring package but it was already present.

Restarting the php-fpm service solved the error 500.

php sessions

After solving the previous error, I got the following error:

enter image description here

/etc/phpmyadmin/config.inc.php had the line

$cfg['Servers'][$i]['auth_type'] = 'cookie';

but PHP's session.save_path variable is set to the inexistent /var/lib/php/session folder.

Creating a folder with proper permissions solved this error, I can login properly.

trailing slash redirection

If I try to acess any address on this server without a trailing slash in the end of the URL, nginx is adding a trailing slash and removing its :8080 part. It doesn't happen if I leave the trailing slash.

(eg.: http://localhost:8080/example gets redirected to http://localhost/example/. The fact I have phpMyAdmin running both in the VM and on the host machine added more confusion as I would see the phpMyAdmin login dialog, but on the wrong destination).

It seems to be a common nginx error. I have googled and tried various solutions with no success. If I find a solution for my case I will update this answer.