NGINX phpMyAdmin configuration on server remote

Author: Rafal Marguzewicz
Categories: NGINX

nginxAfter install NGINX ns MariaDb/MySQL we can start install and configuration phpMyAdmin (PMA). This article is for Linux system with remote access (remember security). If you configuring PMA on localhost

The planned environment looks like this:
http://ipserwera/ – blank default page of serwer,
http://ipserwera/panel-pma289/ – page of phpMyAdmin.
/home/<user_name>/www/ – path to web public folder
/usr/share/phpmyadmin/ – default PMA folder location

For improve security we will configure an additional HTTP server password to the location of the PMA.

1. Installation phpMyadmin

sudo apt install phpmyadmin

Do not choose 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 NGINX for phpMyAdmin

File content /etc/nginx/server_blocks.conf

server {
#set ip your server in server_name
        listen 80 default_server;
        root /home/<user>/www/default/;
        include global.conf;

        location /panel-pma289/ {
                alias /usr/share/phpmyadmin/;
              #  auth_basic "Administrator Login";
              # auth_basic_user_file /home/<user>/www/default/.htpasswd;

                location ~ ^/panel-pma289/(.+\.php)$ {
                        alias /usr/share/phpmyadmin/$1;
                        include fastcgi.conf;
#allow to open only files from list
                location ~* ^/panel-pma289/(.+\.(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. Package of configuration files. More information you can find in article Installation LEMP Linux Nginx MariaDB PHP. 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://your_ip_address/panel-pma289/

3. NGINX – login and pass to location of PMA

To improve security can set additional login/password. Need generate file .htpasswd with login and password hash. There are many offline and online tools to generate file .htpasswd. Example file .htpasswd which login is user and password is pass.
Copy the file to /home/<user>/www/default/.htpasswd and next uncomment line auth_basic "Administrator Login" and auth_basic_user_file in config NGINX
Reload nginx and check result of work.

4. Possible problems

NGINX: bad address of configuration folders, syntax errors config.
Linux: permissions (chmod lub chown) to files or folders. Problems with install packages.
SQL: bad password to root

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:
Yii2: configuration of the framework, components and modules

Configuration file Yii2 basic template is in the path config/web.php. In case of configuration Yii2 advanced template, frontend and backend...