Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
share|improve this question
4  
This question got 4 votes-to-close. Why? meta.superuser.com/questions/6455/… –  That Brazilian Guy Mar 7 '13 at 15:32

3 Answers 3

up vote 3 down vote accepted
+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.

share|improve this answer

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

Add the following line:

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

share|improve this answer
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. –  Lorenzo Von Matterhorn Mar 6 '13 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. –  That Brazilian Guy Mar 8 '13 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. –  That Brazilian Guy Mar 14 '13 at 16:52

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.

share|improve this answer
    
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. –  That Brazilian Guy Mar 14 '13 at 16:47
    
Your suggestion for looking for log files, however, has put me in the right direction. –  That Brazilian Guy Mar 14 '13 at 16:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.