NGINX phpMyAdmin configuration on localhost

Author: Rafal Marguzewicz
Categories: DevOps

nginxIf NGINX and MariaDb/MySQL are installed, can start install and configuration phpMyAadmin (PMA). This article is for Linux system. If you need phpMyAdmin on server with access from internet, recommended see article NGINX phpMyAdmin configuration – remote server

The planned configuration:
http://localhost/ – index of all public folders
http://localhost/panel-pma/ – phpMyAdmin page.
For improve work leve with phpMyAdmin, we will configure login without password and disable the session security (token)
When if you do not use PMA for some time, you will not log us out.

1. Installation phpMyadmin

sudo apt install phpmyadmin

Do not select apache2 and lighthttp but click tab and ok. Then you will be asked for password to SQL server.
phpmyadmin install on debian
Defaul folder of PMA /usr/share/phpmyadmin/ (if in your system will be different, remember about change configuration)

2. Configuration HTTP server

Example config NGINX:

server {
	listen 80;
	server_name localhost;

# path to folder to all web sites
	root /home/<user>/Desktop/localhost;
	index index.php index.html index.htm;
	include global.conf;

# list of subfolders   
location / {
	autoindex on;

location ~ \.php$ {
	try_files $uri =404;
	include fastcgi.conf;

	location /panel-pma/ {
# path to folder PMA
		alias /usr/share/phpmyadmin/;

		location ~ ^/panel-pma/(.+\.php)$ {
			alias /usr/share/phpmyadmin/$1;
			include fastcgi.conf;
		location ~* ^/panel-pma/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
     		  	 alias /usr/share/phpmyadmin/$1;

In my configuration, I use edited files fastcgi.conf and global.conf. More information you can find in article Installation LEMP Linux Nginx MariaDB PHP7. Without them in folder /etc/nginx/, NGiNX return exception.

After save file can reload configuration

sudo service nginx reload

And PMA is avaialbe on URL http://localhost/panel-pma/

3. Configuration PMA

  • Automatically login user
    Edit the file /etc/phpmyadmin/ – for set login without password add/or edit fallow text code
    $cfg['Servers'][$i]['AllowNoPassword'] = TRUE;
    Change authorisation tupe from cookie to config
    $cfg['Servers'][$i]['auth_type'] = 'config';

    Then set login and password
    $cfg['Servers'][$i]['user'] = 'root';
    $cfg['Servers'][$i]['password'] = '';

    PMA from one panel can manage many databases SQL, forthat you need to change
    $i = 1; and delete all increment ($i++;)

    All example file /etc/phpmyadmin/

     * Debian local configuration file
    if (!function_exists('check_file_access')) {
        function check_file_access($path)
            if (is_readable($path)) {
                return true;
            } else {
                    'phpmyadmin: Failed to load ' . $path
                    . ' Check group www-data has read access and open_basedir restrictions.'
                return false;
    // Load secret generated on postinst
    if (check_file_access('/var/lib/phpmyadmin/')) {
    // Load autoconf local config
    if (check_file_access('/var/lib/phpmyadmin/')) {
    if (check_file_access('/etc/phpmyadmin/config-db.php')) {
    $i = 1;
    $cfg['Servers'][$i]['host'] = 'localhost';
    $cfg['Servers'][$i]['AllowNoPassword'] = TRUE;
    $cfg['Servers'][$i]['auth_type'] = 'config';
    $cfg['Servers'][$i]['user'] = 'root';
    $cfg['Servers'][$i]['password'] = '';
    $cfg['UploadDir'] = '';
    $cfg['SaveDir'] = '';
  • Disable sesion token:
    Edit file /usr/share/phpmyadmin/libraries/ In line 480 add$token_mismatch = false;

    $token_mismatch = true;
    $token_provided = false;
    if (PMA_isValid($_REQUEST['token'])) {
        $token_provided = true;
        $token_mismatch = ! hash_equals($_SESSION[' PMA_token '], $_REQUEST['token']);
    $token_mismatch = false;

4. Possible problems

Linux: permissions (chmod lub chown) to files or folders. Problems with install packages. NGINX: bad address of configuration folders, syntax errors config. SQL: bad password to root, not the correct installation MariaDb. In case of problems, more information is needed: If syntax error in configuration file of NGINX fallow command, print out line with mistake:
sudo nginx -t

Invalid folder address or permissions, logs should help

sudo nano /var/log/nginx/error.log

With SQL server problem, check password in terminal

mysql -u root -p

Your email address will not be published. Required fields are marked *

Name *
Email *

Read previous post:
Installation LEMP – Linux Nginx MariaDB PHP7

If we have installed Linux system, we can to go install the rest of the kit LEMP Linux, NGINX, MariaDb...