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
1

3 Answers 3

5
+50

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;

3
  • 3
    hello and welcome to SuperUser. please take some time explaining the syntax and details about what those command lines will perform. it may be relevant for future readers or to the QA himself. Mar 6, 2013 at 14:58
  • I can't even see the phpmyadmin login screen. I've added the line to the cfg file, but it didn't fix the problem. Mar 8, 2013 at 19:01
  • docs.phpmyadmin.net/en/latest/config.html states the default value is true. I haven't set it to false, and it's not present on the config file. Mar 14, 2013 at 16:52
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.

2
  • I'm not running two webserver configurations on the same machine. 8080 is a NAT redirect port for the guest VM, and 80 is the port for the host OS. Technically, they are on the same machine, but virtualized from each other. Mar 14, 2013 at 16:47
  • Your suggestion for looking for log files, however, has put me in the right direction. Mar 14, 2013 at 16:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .