How to add /phpmyadmin section to your sites

1 min read

How to install and enable phpMyAdmin at your server with Nginx on /phpmyadmin uri.

Get PMA sources

Go to /usr/share directory.

cd /usr/share

Download sources. Check the latest version on the offical site.

wget https://files.phpmyadmin.net/phpMyAdmin/4.8.1/phpMyAdmin-4.8.1-all-languages.zip unzip phpMyAdmin-4.8.1-all-languages.zip mv phpMyAdmin-4.8.1-all-languages phpmyadmin

Create a snippet for Nginx

Create a new snippet file.

nano /etc/nginx/snippets/phpmyadmin-location.conf

Put the following location params to this file.

location /phpmyadmin { # Path to parent folder for phpmyadmin's sources root /usr/share; index index.php index.html index.html; # Resolve static files location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { try_files $uri =404; } # Process php files location ~ ^/phpmyadmin/(.+\.php)$ { # Check out path to php processor # It could be a socket file or hostname:port param fastcgi_pass unix:/var/run/php/php5.6-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; try_files $uri =404; } }

Usage

Now you can include snippet in site's config.

server { ... # Processor for /phpmyadmin location include snippets/phpmyadmin-location.conf; ... }

Result

Open /phpmyadmin uri on your site.