How to Install phpMyAdmin with Apache on Ubuntu 24.04 or 22.04 LTS

Heyan Maurya
11 Min Read

Tutorial to learn the steps for installing phpMyAdmin on Ubuntu 24.04 Noble or 22.04 LTS Jammy JellyFish using Apache Web server for managing MariaDB or MySQL via web browser and graphical user interface.

phpMyAdmin is a popular open-source software for managing databases that is available on almost all web hosting services. However, if you manage your hosting or cloud server yourself, then you have to install this Database management software yourself.

The program offers a graphical interface with numerous options. These can refer to a complete database and include, for example:

Creating a new database
Delete an existing database
Copy the content to a new database
Backup in a backup
Restore from an existing backup
Transferring from one server to another
Changing users and passwords
Manipulation of access rights

We can perform complex and time-consuming tasks without dealing with commands and their structure with the help of phpMyAdmin. These include, but are not limited to:

Find variable names or content in databases
Replacing Values
Encryption of plain text using different algorithms, e.g. passwords
Multiple selections of variables via the graphical interface
Checking databases for internal consistency and other errors
Create and delete entries, parameters, or values
Create, copy, or remove individual tables
Clear presentation of the structure of databases

Let’s learn how to install phpMyAdmin on Ubuntu 24.04 or 22.04 Server. The steps given here will also be the same for other versions of this Linux.

Steps to install phpMyAdmin on Ubuntu 24.04 or 22.04 Server

Estimated reading time: 37 minutes

1. phpMyAdmin Requirements

To perform this tutorial, we require a Ubuntu server, a non-root sudo user access, an Apache web server, a Database, PHP, and an active internet connection.

2. Update the Ubuntu 24.04 or 22.04 Server

First, we should update our Linux server because most of the packages we need to set up phpMyAdmin will come from the default Ubuntu Jammy JellyFish repository.

sudo apt update && sudo apt upgrade

Also, install:

sudo apt install wget nano

3. Install the LAMP server

We need LAMP Stack, which refers to a software bundle comprised of Apache, MySQL/MariaDB, and PHP installed on a Linux server. For the Linux server, we are using Ubuntu; we will install the rest in this step.

Apache Webserver

Apache is an open-source web server that is available to install directly using Ubuntu’s default repository:

sudo apt install apache2

Enable its server:

sudo systemctl enable apache2
sudo systemctl restart apache2

Setup MariaDB server

Next, install the MariaDB server, which is a fork of MySQL that works exactly like Apache. It is also available to set up using the default system repository.

sudo apt install mariadb-server mariadb-client

Enable and start 

sudo systemctl enable --now mariadb

Also, secure your MariaDB installation:

sudo mysql_secure_installation

You will get a text-based wizard to secure your database server as you run the above command. Here are the questions it will ask:

Enter current password for root (enter for none): Press ENTER.
Switch to unix_socket authentication? Press N, then ENTER.
Change the root password? Press Y, then ENTER.
Remove anonymous users? Press Y, then ENTER.
Disallow root login remotely? Press Y, then ENTER.
Remove test database and access to it? Press Y, then ENTER.
Reload privilege tables now? Press Y, then ENTER.

Install PHP and its extension

phpMyAdmin is a PHP-based SQL database management software, hence we need this scripting language on our Ubuntu system and some common PHP extensions.

sudo apt install php php-{fpm,mbstring,bcmath,xml,mysql,common,gd,cli,curl,zip}

Also, enable PHP fpm to start with FPM, if not already:

sudo systemctl enable php8.1-fpm --now

4. Install phpMyAdmin on Ubuntu 24.04 or 22.04

Well, one way to install phpMyAdmin is to use the APT package manager to download and install it using Ubuntu’s repository. However, one should be aware that the version of phpMyAdmin installed using APT will not be the latest one. This is because the long-term version of Ubuntu uses extremely stable packages, so you won’t get the latest release of the software. In such a situation, we can manually download the package of phpMyadmin to configure. Let’s see how to do that.

Download phpMyAdmin’s latest version.

The command will automatically fetch and save the latest phpMyAdmin compressed file in Tar format. Just copy and execute it in your command terminal:

wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz

Extract and configure

Once the file is downloaded to your system, extract it and move it to your webroot directory.

Extraction:

tar xvf phpMyAdmin-*-all-languages.tar.gz

Now, move it:

sudo mv phpMyAdmin-*/ /var/www/html/phpmyadmin

Also, remember to create a Temporary folder called ‘tmp‘ inside the extracted directory; otherwise, the phpMyAdmin interface will generate a warning.

sudo mkdir -p /var/www/html/phpmyadmin/tmp

5. Add Blowfish cipher string

To work correctly, phpMyAdmin needs a Blowfish cipher string in the configuration file for cookie authentication. However, by default, there is no main configuration file because we manually set up the phpMyAdmin. Instead, there is a sample configuration file that we can rename and use. Here is a command for that:

sudo cp /var/www/html/phpmyadmin/config.sample.inc.php /var/www/html/phpmyadmin/config.inc.php

Now, generate a 32-bit random string:

openssl rand -base64 32
Generate random 32 bit string for BowlFish

Copy the string generated by the above command:

Now, edit the phpMyAdmin configuration file

sudo nano /var/www/html/phpmyadmin/config.inc.php

And past it in the front of the line :

$cfg[‘blowfish_secret’] = ‘your-key‘; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

Replace your key with the generated code.

Also, scroll down to the end and add this line.

$cfg['TempDir'] = '/var/www/html/phpmyadmin/tmp';
BowlFish secret key for phpMyAdmin

After that, save your file by pressing Ctrl+O, hitting the Enter key, and exiting the file editor- Ctrl+X.

Give Apache permission to access PHPMyAdmin files:

sudo chown -R www-data:www-data /var/www/html/phpmyadmin

File and directory permission:

sudo find /var/www/html/phpmyadmin/ -type d -exec chmod 755 {} \;
sudo find /var/www/html/phpmyadmin/ -type f -exec chmod 644 {} \;

6. Create an Apache Vhost configuration file

We don’t want to serve the phpMyAdmin user interface on our root domain or IP address, so we either use a subdomain or a subfolder. Here, we are serving it in a subfolder. Thus, create a configuration file for it.

sudo nano /etc/apache2/conf-available/phpmyadmin.conf

Copy Paste the following lines:

Alias /phpmyadmin /var/www/html/phpmyadmin

<Directory /var/www/html/phpmyadmin>
Options Indexes FollowSymLinks
DirectoryIndex index.php

<IfModule mod_php8.c>
AddType application/x-httpd-php .php

php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_value include_path .
</IfModule>

</Directory>

# Authorize for setup
<Directory /var/www/html/phpmyadmin/setup>
<IfModule mod_authn_file.c>
AuthType Basic
AuthName "phpMyAdmin Setup"
AuthUserFile /etc/phpmyadmin/htpasswd.setup
</IfModule>
Require valid-user
</Directory>

# Disallow web access to directories that don't need it
<Directory /var/www/html/phpmyadmin/libraries>
Order Deny,Allow
Deny from All
</Directory>
<Directory /var/www/html/phpmyadmin/setup/lib>
Order Deny,Allow
Deny from All
</Directory>

Save the file- Ctrl+O, hit Enter, and exit using Ctrl+X.

Activate new configuration:

sudo a2enconf phpmyadmin.conf

Restart the Apache Webserver

To make the changes apply successfully, restart the Apache webserver.

sudo systemctl restart apache2

7. Access the phpMyAdmin web interface

Enter the server IP address or domain name along with /phpmyadmin folder in the browser URL to access this web database management platform.

For example:

https://server-ipaddress/phpmyadmin

or

http://your-domain.com/phpmyadmin

Enter the MySQL database root user and password to log in to phpMyAdmin.

Login phpMyAdmin on ubuntu 22.04 server
Install phpMyAdmin on Ubuntu 22.04 Jammy using Apache

Note: If you get this notification at the footerthe phpMyAdmin configuration storage is not completely configured; some extended features have been deactivated. Find out why. Alternatively, go to the ‘Operations’ tab of any database to set it up there.

Create Storage space

Then simply click on the Find out why link and click the “Create” link to create automatically phpmyadmin database.

Create Storage space phpmyadmin ubuntu 22.04

Conclusion

In this way, we can swiftly install the phpMyAdmin on Ubuntu 24.04 or 22.04 LTS Jammy to manage our MySQL or MariaDB database with the help of a web-based graphical user interface.  Because of its security, extensive functionality, and comfortable operation, PhpMyAdmin is considered the standard for administering MySQL and MariaDB databases. It is included in web hosting offers at many Internet Service Providers (ISPs) and is usually part of the basic configuration of Dedicated and Linux Virtual Servers (VPS). The most common tasks include regularly creating a backup, transferring databases to other servers, and troubleshooting technical failures.

For more, you can visit the official documentation.

Other Articles:

How to access remote MySQL database in local phpMyAdmin
How to Install phpMyAdmin on Debian 11 Bullseye (Apache)
Install the Siege Benchmarking Tool on Ubuntu 24.04 or 22.04
How to Install PowerShell on Ubuntu 24.04 or 22.04 LTS

11 Comments
  • After execution this line “sudo systemctl enable -now mariadb”, this error comes “Failed to parse lines ‘ow”
    Any solution?

  • The tutorial was excellent. The steps were precise and very well illustrated. However, after logging into phpmyadmin and getting the …configuration storage is not completely configured… message, selecting Find out why and selecting Create, I still ended up with a message ‘The secret passphrase in configuration (blowfish_secret) is not the correct length. It should be 32 bytes long.’ I am sure I used the exact openssl rand command. The length of the generated string is 44 characters long. Could the rand directive be at fault?

  • hey man i followed all the steps and everything seemed to work but when i try to enter the ip address in my browser it shows “connection failed”

  • Hi,
    Thanks for this clear and well thought tutorial.
    As I am moving my web-dev activity from OSX & phpstorm to Ubuntu I think I know pretty well the MAMP stack components.
    But as Linux is different, I did follow carefully all the steps mentioned, double checking each cut/paste entry… and I did it twice.
    which means I also know how to “desinstall” the package.
    Unfortunately, at the end, I can’t reach the PMA app through the browser with the classical “localhost/phpmyadmin”. (with or without ports indication).
    I had the same issue with all the other tutorials i tried, from Ubuntu, DigitalOcean, CloudBooklet and the others.
    The issue isn’t with the tutorial but with something I don’t do well or that’s wrong on my Ubuntu 20.04 PC .
    In other words I am stranded.
    Any idea about what could go wrong ???
    Thanks for any help as it drives me nuts .
    Marc

    • Instead of using manual installation, use the APT package manager to install the phpMyAdmin:

      sudo apt install phpmyadmin

  • Everything goes smoothly until the phpmyadmin asks for username and password.

    I’ve double-checked everything and I’ve also found that almost ALL instructions on the internet on how to do this result in smooth install, but with the inability to actually login into the phpmyadmin interface.

    I’ve even gone so far as to create, as root, an admin2 user with password and it still fails. . .
    mysqli::real_connect(): (HY000/1698): Access denied for user ‘admin2’@’localhost’

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.