Website Vidya
DeploymentStep-by-Step Guide

How to Install phpMyAdmin on Ubuntu 24.04

Learn how to install phpMyAdmin on Ubuntu 24.04 LTS with Apache and Nginx web servers. Complete guide covering MySQL authentication, security alias, and SSL.

RR
Rajesh RayLead Systems Educator
Published:
6 min read
PDF Cheat Sheet
How to Install phpMyAdmin on Ubuntu 24.04
AI Executive SummaryCORE CIS AI

6 min read

Learn how to install phpMyAdmin on Ubuntu 24.04 LTS with Apache and Nginx web servers. Complete guide covering MySQL authentication, security alias, and SSL.

Key Highlights
  • Prerequisites and Supported Releases
  • Step 1: Updating System Packages and Installing Prerequisite PHP Extensions
  • Step 2: Installing phpMyAdmin Package via APT
Grounded in full engineering runbookCORE CIS Ai Engine

Interactive Builder for this Guide

Build your custom nginx syntax (How to Install phpMyAdmin on Ubuntu 24.04)

Generated Config Output
server {
    listen 80;
    listen [::]:80;
    server_name app.example.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name app.example.com;

    ssl_certificate /etc/letsencrypt/live/app.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/app.example.com/privkey.pem;

    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;

    gzip on;
    gzip_types text/plain text/css application/json application/javascript application/xml;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}
Production Nginx reverse proxy -> 127.0.0.1:3000 for app.example.com.
Flag-by-Flag Breakdown
server_nameBinds this virtual host to app.example.com
return 301 https://...Redirects all plain HTTP requests permanently to TLS/HTTPS
proxy_pass http://127.0.0.1:3000Forwards HTTP + WebSocket requests to local application server
X-Content-Type-Options / X-Frame-OptionsProtects users against MIME sniffing and clickjacking

phpMyAdmin is a free, open-source web-based database administration tool built with PHP. It provides an intuitive graphical user interface (GUI) that allows developers and system administrators to manage MySQL and MariaDB databases without having to execute complex SQL queries from the terminal command line.

Through phpMyAdmin, administrators can create and drop databases, manage database user privileges, execute custom SQL queries, optimize database tables, export backups in multiple formats (SQL, CSV, XML), and import large data dumps seamlessly. Learning how to install phpmyadmin on ubuntu 24.04 provides a dependable, visual database management system across both Apache and Nginx web servers.

In this comprehensive step-by-step tutorial, we demonstrate how to install phpMyAdmin on Ubuntu 24.04 LTS (Noble Numbat). We cover installing prerequisite PHP extensions, deploying phpMyAdmin from official Ubuntu repositories, configuring Apache and Nginx web server integrations, creating a dedicated MySQL administrative superuser, changing the default URL access path, adding HTTP Basic Authentication, and enforcing SSL encryption.

Advertisement

Prerequisites and Supported Releases

This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat). The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.

Before proceeding, ensure you have the following requirements satisfied:

  • A server or virtual machine running Ubuntu 24.04 LTS.
  • A non-root user account configured with administrative sudo privileges.
  • A LAMP or LEMP web stack installed (Apache/Nginx, PHP 8.3, and MySQL/MariaDB).
  • Open incoming HTTP port 80 and HTTPS port 443.

Step 1: Updating System Packages and Installing Prerequisite PHP Extensions

phpMyAdmin requires several core PHP extensions to interact with MySQL databases, process internationalized character sets, and handle compressed file archives.

First, refresh your APT package repository index and upgrade installed packages.

Install PHP 8.3 along with essential extensions including php-mbstring, php-zip, php-gd, php-json, and php-curl using APT.

Advertisement

Enable the required PHP extensions to ensure that phpMyAdmin can handle multi-byte string operations and compressed database exports.

# Update APT package index and upgrade packages
sudo apt update && sudo apt upgrade -y

# Install required PHP extensions for phpMyAdmin
sudo apt install -y php php-mbstring php-zip php-gd php-json php-curl php-mysql

# Verify PHP version
php -v

Step 2: Installing phpMyAdmin Package via APT

Ubuntu 24.04 includes the stable phpMyAdmin package in its default universe repositories.

Install phpmyadmin using the APT package manager.

During installation, the package installer presents interactive configuration dialogs:

Web server selection: If using Apache, press Space to select [*] apache2 and press Enter. If using Nginx, press Tab and Enter to skip selection.

Advertisement

dbconfig-common prompt: Select to allow dbconfig-common to automatically create the internal phpMyAdmin administrative storage database.

MySQL application password: Press Enter to let dbconfig generate a secure, randomized internal password automatically.

# Install phpMyAdmin package
sudo apt install -y phpmyadmin

# Enable the mbstring extension explicitly
sudo phpenmod mbstring

Step 3: Configuring Apache Web Server Integration

If you are using Apache as your web server, the installer provides an automated configuration snippet located at /etc/phpmyadmin/apache.conf.

Enable the phpMyAdmin configuration in Apache using a2enconf phpmyadmin.

Verify the Apache configuration syntax using apache2ctl configtest to ensure there are no syntax errors.

Restart the Apache service to apply changes.

# Enable phpMyAdmin Apache configuration
sudo a2enconf phpmyadmin

# Test Apache configuration syntax
sudo apache2ctl configtest

# Restart Apache web server
sudo systemctl restart apache2

Step 4: Configuring Nginx Web Server Integration

If your server runs Nginx instead of Apache, you must create a symbolic link from phpMyAdmin's installation directory (/usr/share/phpmyadmin) into your Nginx web root directory.

Alternatively, add a dedicated location block inside your Nginx server block configuration file (e.g., /etc/nginx/sites-available/default).

Ensure the location block routes PHP files to the PHP-FPM socket (/run/php/php8.3-fpm.sock).

Test the Nginx configuration syntax and reload Nginx.

# Create symbolic link in web root (for Nginx)
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin

# Or add location directive in Nginx server block:
# location /phpmyadmin {
#     root /usr/share/;
#     index index.php index.html;
#     location ~ ^/phpmyadmin/(.+\.php)$ {
#         try_files $uri =404;
#         fastcgi_pass unix:/run/php/php8.3-fpm.sock;
#         include fastcgi_params;
#         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#     }
# }

sudo nginx -t && sudo systemctl reload nginx

Step 5: Creating a Dedicated MySQL Administrative User

In modern Ubuntu releases, the MySQL root account uses the auth_socket authentication plugin by default, which prevents web-based logins via phpMyAdmin.

For security best practices, never configure a native password for the MySQL root user. Instead, create a dedicated administrative user with full privileges.

Log into the MySQL command line shell using sudo mysql.

Create a new database user (e.g., dbadmin) with a strong, randomized password and grant all administrative privileges.

Flush privileges and exit the MySQL shell.

# Open MySQL root prompt
sudo mysql

# Run the following SQL statements:
# CREATE USER 'dbadmin'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'StrongAdminPass456!';
# GRANT ALL PRIVILEGES ON *.* TO 'dbadmin'@'localhost' WITH GRANT OPTION;
# FLUSH PRIVILEGES;
# EXIT;

Step 6: Hardening Security by Changing the Default URL Alias

The default URL path /phpmyadmin is an immediate target for automated bots, vulnerability scanners, and brute-force dictionary attacks.

Change the default alias to an obscure, custom URL path such as /secure_db_portal or /backend_db_789.

For Apache, edit /etc/phpmyadmin/apache.conf and modify the Alias /phpmyadmin directive.

For Nginx, rename the symbolic link or change the location directive in your server block configuration.

Reload your web server so that malicious scans targeting /phpmyadmin receive a 404 Not Found response.

# For Apache: change alias in /etc/phpmyadmin/apache.conf
sudo sed -i 's|Alias /phpmyadmin /usr/share/phpmyadmin|Alias /secure_db_portal /usr/share/phpmyadmin|' /etc/phpmyadmin/apache.conf
sudo systemctl reload apache2

# For Nginx: rename the symbolic link
sudo mv /var/www/html/phpmyadmin /var/www/html/secure_db_portal
sudo systemctl reload nginx

Step 7: Adding HTTP Basic Authentication for Dual-Layer Protection

Implementing HTTP Basic Authentication adds an essential second authentication barrier. Visitors must provide valid server credentials before they are permitted to even view the phpMyAdmin login prompt.

Install the apache2-utils package to obtain the htpasswd credential generation utility.

Create a secure password file at /etc/phpmyadmin/.htpasswd and generate credentials for an authorized gateway user.

Configure Apache or Nginx to require authentication for your custom phpMyAdmin alias.

Reload your web server and verify that an authentication challenge appears in your browser.

# Install htpasswd utility
sudo apt install -y apache2-utils

# Create password file with user 'gatekeeper'
sudo htpasswd -c /etc/phpmyadmin/.htpasswd gatekeeper

# Enable .htaccess overrides in /etc/phpmyadmin/apache.conf
sudo sed -i '/<Directory \/usr\/share\/phpmyadmin>/a \    AllowOverride All' /etc/phpmyadmin/apache.conf

# Create .htaccess file in /usr/share/phpmyadmin
sudo bash -c 'cat <<EOF > /usr/share/phpmyadmin/.htaccess
AuthType Basic
AuthName "Restricted Database Administration"
AuthUserFile /etc/phpmyadmin/.htpasswd
Require valid-user
EOF'

sudo systemctl reload apache2

Step 8: Accessing phpMyAdmin and Verifying Database Management

Open your web browser and navigate to your custom URL: https://your_domain_or_ip/secure_db_portal.

If HTTP Basic Authentication is enabled, enter your gateway credentials (e.g., gatekeeper).

At the main phpMyAdmin login screen, enter your dedicated database administrative user credentials (e.g., dbadmin and your password).

Once logged in, verify that the phpMyAdmin dashboard displays your MySQL version, active databases, server status, and character encoding settings.

Login URL: https://your_domain_or_ip/secure_db_portal
Gateway Auth: gatekeeper (HTTP Basic Auth)
Database Username: dbadmin
Database Password: StrongAdminPass456!
Dashboard Features: Database Operations, User Privileges, Export/Import, SQL Terminal

Troubleshooting and Common Errors

When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:

Browser displays '404 Not Found' when accessing /phpmyadmin

Resolution: Verify that the Apache configuration is enabled: sudo a2enconf phpmyadmin && sudo systemctl reload apache2. If you changed the URL alias in Step 6, ensure you are visiting the new custom path (e.g., /secure_db_portal).

Login fails with 'mysqli::real_connect(): (HY000/1698): Access denied for user root@localhost'

Resolution: Do not log in using the MySQL 'root' account. In Ubuntu 24.04, root uses socket authentication. Create and log in with a dedicated administrative user (such as 'dbadmin') as detailed in Step 5.

Warning: 'The phpMyAdmin configuration storage is not completely configured'

Resolution: This indicates that the internal phpMyAdmin database was not initialized. Reconfigure the package by executing sudo dpkg-reconfigure phpmyadmin and select '<Yes>' when prompted for dbconfig-common setup.

Security Best Practices and Hardening

Never expose phpMyAdmin on public HTTP port 80; always enforce HTTPS encryption with an automated Let's Encrypt SSL certificate.

Never configure native password authentication for the MySQL root user; use dedicated unprivileged database users with granular grants.

Always change the default URL path (/phpmyadmin) to an unguessable alias and implement HTTP Basic Authentication (.htpasswd) to prevent automated bot probes.

Restrict access to phpMyAdmin by IP address in your web server configuration so only trusted office or VPN IP addresses can connect.

Deepen your Linux system administration skills with our related production-tested guides:

Authoritative References and Official Documentation

Frequently Asked Questions

Quick answers to common questions and configurations

3 FAQs
Yes. phpMyAdmin fully supports MariaDB. The installation steps and database user provisioning commands are completely identical for both MySQL and MariaDB.
Edit your active PHP configuration file (/etc/php/8.3/apache2/php.ini or /etc/php/8.3/fpm/php.ini) and increase upload_max_filesize = 64M and post_max_size = 64M, then restart your web server.
Execute sudo apt purge phpmyadmin followed by sudo apt autoremove --purge to remove the package and clean up configuration files.
RR
Written byVerified Author

Rajesh Ray

I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.

SPAM-FREE MODERATED DISCOURSE

Join the Conversation & Perspective

Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.

AT
MP
JV
+2

No comments on this guide yet. Be the first to share your thoughts or ask a question!

Recommended Reading10 Guides

Related Technical Guides

Tested runbooks, server administration walkthroughs, and troubleshooting guides

Uncategorized•

How to Redirect HTTP to HTTPS in Nginx

If you’re running a website today and it’s still accessible over plain HTTP, you’re already behind. Modern browsers flag non-HTTPS sites as “Not Secure,” search engines favor encrypted websites, and users are far more cautious about where t...

RR
Rajesh Rai
Read More
Featured Infrastructure PartnerUp to 75% OFF + 3 Months Free

Supercharge Your Linux & Cloud Workloads with Hostinger

Deploy high-speed NVMe KVM VPS, Docker containers, and LiteSpeed-accelerated WordPress servers in under 60 seconds with full root access, dedicated IPv4, and 24/7 technical support.

Pure NVMe SSD StorageFull Root Access & SSHFree Domain & Unlimited SSL99.9% Uptime SLA
Plans from$2.99/mo
Claim Hostinger DealAffiliate link • Special discount applied at checkout