In order to use phpmyadmin on your server, you'd of course have to install it and property set it up first:
How to Install phpMyAdmin with Nginx
Then you'll need the following config file for phpmyadmin to work on a public domain.
To do this we simply add a config file in the /etc/nginx/sites-available
:
sudo nano /etc/nginx/sites-available/phpmyadmin
server {
server_name db.example.com;
root /usr/share/phpmyadmin/;
index index.php index.html index.htm index.nginx-debian.html;
access_log /var/log/nginx/phpmyadmin_access.log;
error_log /var/log/nginx/phpmyadmin_error.log;
location / {
index index.php;
try_files $uri $uri/ =404;
location ~^/(doc|sql|setup)/ {
deny all;
}
location ~ /(.+\.php)$ {
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
include snippets/fastcgi-php.conf;
}
}
}
And then enable the file by creating a link from it to the sites-enabled directory:
sudo ln -s /etc/nginx/sites-available/phpmyadmin /etc/nginx/sites-enabled/
Test for syntax errors:
sudo nginx -t
Restart Nginx to enable your changes:
sudo systemctl restart nginx