Matomo Analytics

This guide covers installing phpMyAdmin using Ploi's 1-click installer and manual installation on Ubuntu servers.

Installation via Ploi (Recommended)

Prerequisites

  • A server provisioned through Ploi

  • MySQL or MariaDB installed on the server (phpMyAdmin is not available for PostgreSQL)

  • An existing site where you want to install phpMyAdmin

Step-by-Step installation

  1. Navigate to your site

    • Go to your server in the Ploi dashboard

    • Select the site where you want to install phpMyAdmin

  2. Select phpMyAdmin

    • Find phpMyAdmin in the installers list

    • Click on the phpMyAdmin card

  3. Install

    • Click the "Install phpMyAdmin" button

    • The installation status will show "phpMyAdmin is currently installing, please hold on"

    • Wait for the installation to complete (typically 1-2 minutes)

  4. Access phpMyAdmin

    • Once installed, a phpMyAdmin panel will appear showing your domain

    • Click "Open phpMyAdmin" to access the interface

    • Log in using your database credentials

Adding SSL (Recommended)

After installation, you can secure phpMyAdmin with SSL:

  1. Navigate to your server's Services section

  2. Find phpMyAdmin in the services list

  3. Click "Install SSL"

  4. Ploi will automatically provision a Let's Encrypt certificate

Uninstalling

To remove phpMyAdmin:

  1. Navigate to your site in Ploi

  2. Find the phpMyAdmin section

  3. Click the "Uninstall" button

  4. Confirm the uninstallation


Manual installation on Ubuntu

This section covers manual installation on Ubuntu servers with Nginx and PHP already configured.

Prerequisites

  • Ubuntu 20.04/22.04/24.04

  • Nginx installed and running

  • PHP 8.x with FPM installed

  • MySQL or MariaDB installed

  • Root or sudo access

Step 1: Install required PHP extensions

sudo apt update
sudo apt install -y php-mbstring php-zip php-gd php-json php-curl

Step 2: Download phpMyAdmin

cd /tmp
wget https://files.phpmyadmin.net/phpMyAdmin/5.2.1/phpMyAdmin-5.2.1-all-languages.tar.gz
sudo mkdir -p /usr/share/phpmyadmin
sudo tar -xzf phpMyAdmin-5.2.1-all-languages.tar.gz -C /usr/share/phpmyadmin --strip-components=1

Step 3: Configure phpMyAdmin

# Create temp directory for sessions
sudo mkdir -p /usr/share/phpmyadmin/tmp
sudo chmod 777 /usr/share/phpmyadmin/tmp

# Create configuration file
sudo cp /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php

# Generate a random blowfish secret (32 characters)
BLOWFISH_SECRET=$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | head -c 32)

# Update the configuration
sudo sed -i "s/\$cfg\['blowfish_secret'\] = '';/\$cfg['blowfish_secret'] = '$BLOWFISH_SECRET';/" /usr/share/phpmyadmin/config.inc.php
sudo sed -i "s/\$cfg\['Servers'\]\[\$i\]\['host'\] = 'localhost';/\$cfg['Servers'][\$i]['host'] = '127.0.0.1';/" /usr/share/phpmyadmin/config.inc.php

Step 4: Create symlink

sudo ln -sf /usr/share/phpmyadmin /var/www/html/phpmyadmin

Step 5: Configure nginx

Create a new Nginx configuration file:

sudo nano /etc/nginx/sites-available/phpmyadmin

Add the following configuration (replace your-domain.com with your actual domain and adjust PHP version as needed):

server {
    listen 80;
    listen [::]:80;

    server_name your-domain.com;
    root /var/www/html;

    index index.php index.html;

    location /phpmyadmin {
        alias /usr/share/phpmyadmin;
        index index.php;

        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
            fastcgi_param SCRIPT_FILENAME $request_filename;
        }
    }

    location ~ /\.ht {
        deny all;
    }
}

Enable the site and reload Nginx:

sudo ln -sf /etc/nginx/sites-available/phpmyadmin /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Step 6: Set permissions

sudo chown -R www-data:www-data /usr/share/phpmyadmin

Step 7: Access phpMyAdmin

Open your browser and navigate to:

http://your-domain.com/phpmyadmin

Log in using your MySQL/MariaDB credentials.

Optional: Add SSL with Certbot

# Install Certbot if not already installed
sudo apt install -y certbot python3-certbot-nginx

# Obtain SSL certificate
sudo certbot --nginx -d your-domain.com --non-interactive --agree-tos -m [email protected]

Security considerations

phpMyAdmin exposes your database management interface to the web. Consider these security measures:

Recommended alternatives

For better security, consider using desktop database clients that connect via SSH tunnel:

  • TablePlus (macOS, Windows, Linux)

  • Sequel Pro / Sequel Ace (macOS)

  • DBeaver (Cross-platform)

  • MySQL Workbench (Cross-platform)

If you must use phpMyAdmin

  1. Always use HTTPS - Install an SSL certificate

  2. Restrict access by IP - Add IP restrictions in Nginx:

    location /phpmyadmin {
        allow 123.456.789.0;  # Your IP
        deny all;
        # ... rest of config
    }
    
  3. Use strong database passwords - Ensure all database users have strong, unique passwords

  4. Keep phpMyAdmin updated - Regularly update to the latest version

  5. Consider HTTP Basic Auth - Add an additional authentication layer:

    sudo apt install apache2-utils
    sudo htpasswd -c /etc/nginx/.htpasswd admin
    

    Then add to Nginx config:

    auth_basic "Restricted Access";
    auth_basic_user_file /etc/nginx/.htpasswd;
    
Dennis Smink

Written by Dennis Smink

Dennis brings over 6 years of hands-on experience in server management, specializing in optimizing web services for scalability and security.

Start free trial