Skip to content

Instantly share code, notes, and snippets.

@leregi
Created July 10, 2020 13:34
Show Gist options
  • Save leregi/162f68deaf32dab6e2cace617acb864e to your computer and use it in GitHub Desktop.
Save leregi/162f68deaf32dab6e2cace617acb864e to your computer and use it in GitHub Desktop.
How to Install phpMyAdmin with Nginx (LEMP) on Ubuntu
Step 1: Download and Install phpMyAdmin
sudo apt update
sudo apt install phpmyadmin
**During the installation, it will prompt you to select a web server to configure. Nginx isn’t in the list, so press the Tab key and hit OK to skip this step.
Step 2: Create Nginx Server Block
We will configure it so that we can access phpMyAdmin via a sub-domain. Paste the following text into the file. Replace pma.example.com with your actual sub-domain and don’t forget to create an A record for it.
server {
listen 80;
listen [::]:80;
server_name pma.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 / {
try_files $uri $uri/ /index.php;
}
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;
}
location ~ /\.ht {
deny all;
}
}
Your phpMyAdmin files are in /usr/share/phpmyadmin/ directory. Save and close the file. Then test Nginx configurations.
sudo nginx -t
If the test is successful, reload Nginx for the changes to take effect.
sudo systemctl reload nginx
Now you should be able to access phpMyAdmin web interface via
pma.example.com or *localhost* if your running on your local computer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment