8

I've installed phpMyAdmin, but I can't open it on any browser: I get a 301 redirect(*) if I browse to http://localhost:8080/phpmyadmin. If I add a / to the end of the addres, I get a 500 error status instead.

(*) captured using Wireshark. If I use netcat from the terminal on the same host, I get a 301 redirect to a different address.

The environment is a VM I've built for development/testing purposes, where I installed a LEMP (Linux / Nginx / MySQL / PHP) environment. It's a clean install of CentOS 6 64bit running as guest on a Ubuntu 12.04 64bit host. The VM is running in NATed mode with port forwarding. I can open http://localhost:8080 on the guest machine and see the nginx welcome page. I can open a phpinfo page as well, so I know PHP is running.

I have installed the nginx, MySQM, PHP and phpMyAdmin packages each separately. I'm using the default settings for phpMyAdmin. After installig MySQL, I have ran the mysql_secure_installation command and, among other options, I disabled remote root access.

Here are my configuration files:

  • /etc/php.ini: link
  • /etc/php.d/mysql.ini: link
  • /etc/nginx/nginx.conf: link
  • /etc/nginx/conf.d/default.conf: link (In order to run PHP scripts, I have customized it, following online tutorials, and I'm not really sure of what I was doing.)
  • /etc/phpMyAdmin/config.inc.php: link

3 Answers3

5

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.

0

Root logins must be allowed on the /etc/phpmyadmin/config.inc.php configuration file.

Add the following line:

$cfg['Servers'][$i]['AllowRoot'] = TRUE;

Pbarney8
  • 9
  • 2
0

Check your /var/log/nginx/error.log to see what the error 500 says.

It looks like you're running two configurations (one on port 80 and another on 8080) which may conflict.

kevin
  • 2,442