2 Installing phpMyAdmin
Arnaud Lier edited this page 2024-04-01 06:35:51 +00:00

Prerequisites

For the sake of this tutorial, we will assume that NGINX and Certbot are already configured and installed. If this is not the case, here are some tutorials that may help you from other sources:

Obtaining a Certificate for your phpMyAdmin domain

First of all, we are going to make sure NGINX is off while we obtain the certificate. We are going to do this by executing this command:

systemctl stop nginx

Second of all, we are going to obtain the certbot certificate.

certbot certonly

This will now appear with 3 options, you will want to select option that says own webserver.

Next, it will ask you for your domain.

Installing phpMyAdmin

Ubuntu and Debian :

mkdir /var/www/phpmyadmin

cd /var/www/phpmyadmin

wget https://files.phpmyadmin.net/phpMyAdmin/5.2.1/phpMyAdmin-5.2.1-all-languages.zip

unzip phpMyAdmin-5.2.1-all-languages.zip

cd phpMyAdmin-5.2.1-all-languages

mv * /var/www/phpmyadmin

cd /var/www/phpmyadmin

rm -rf phpMyAdmin-5.2.0-all-languages

Now that we have installed phpMyAdmin we are going to setup the phpMyAdmin nginx configuration file. Execute these commands :

nano /etc/nginx/sites-available/phpmyadmin.conf

Then copy and paste the code below, but please replace the sections with your domain e.g. phpmyadmin.example.org

server {
  listen 80;
  server_name <domain>;
  return 301 https://$server_name$request_uri;
}

server {
  listen 443 ssl http2;
  server_name <domain>;

  root /var/www/phpmyadmin;
  index index.php;

  location / {
    try_files $uri $uri/ =404;
  }

  location ~ .php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php8.1-fpm.sock;
  }

  ssl_certificate /etc/letsencrypt/live/<domain>/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/<domain>/privkey.pem;
  ssl_session_cache shared:SSL:10m;
  ssl_protocols TLSv1.2 TLSv1.3;
}

⚠️ Warning ⚠️

This configuration will work if you are using PHP 8.1, replace the line fastcgi_pass with the PHP version installed on your system.

Once we have done that we are going to execute the following commands to finish the installation!

ln -s /etc/nginx/sites-available/phpmyadmin.conf /etc/nginx/sites-enabled/phpmyadmin.conf

phpMyAdmin is now fully configured. You can use it perfectly at the domain you have set! Please make sure to remember to use https instead of http!