Tutorial to learn installation steps of phpMyAdmin on Ubuntu 22.04 LTS Jammy JellyFish using Apache web server to manage MariaDB or MySQL via web browser and GUI.
phpMyAdmin is a popular open source software that we can get on almost any web hosting service for database management. However, if you manage your hosting or cloud server yourself, you must install this database management yourself.
The program offers a graphical interface with many options. These can refer to a complete database and include, for example:
• Creation of a new database
• Delete an existing database
• Copy content to a new database
• Save to save
• Restore from an existing backup
• Transfer from one server to another
• Changing users and passwords
• Manipulation of access rights
We can perform complex and time-consuming tasks without having to manage commands and their structure using phpMyAdmin. These include, but are not limited to:
• Search for variable names or content in databases
• Replacing values
• Plain text encryption using different algorithms, e.g. passwords
• Multiple variable selections via GUI
• Checking databases for internal consistency and other errors
• Create and delete entries, parameters or values
• Create, copy or delete individual tables
• Clear presentation of database structure
Let’s learn how to install phpMyAdmin on Ubuntu 22.04 Server, however, the steps given here will also be the same for other versions of this Linux.
Steps to Install phpMyAdmin on Ubuntu 22.04 Server
1. Requirements
To run this tutorial, we need an Ubuntu server, non-root sudo user access, an Apache web server, database, PHP, and an active internet connection.
2. Update Ubuntu Server 22.04
The first thing we need to do is update our Linux server, as most of the packages we need to configure 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 bundle of software consisting of Apache, MySQL/MariaDB and PHP installed on a Linux server. Well, for Linux server here we are using Ubuntu while we will install the rest in this step.
Apache webserver
Apache is an open source web server that can be installed directly using Ubuntu’s default repository:
sudo apt install apache2
Activate its server:
sudo systemctl enable apache2
sudo systemctl restart apache2
Configure MariaDB Server
Next, install the MariaDB server which is a fork of MySQL and works exactly the same. Just like apache, it is also available to be configured using the default system repository.
sudo apt install mariadb-server mariadb-client
Activate and start
sudo systemctl enable -now mariadb
Also secure your MariaDB installation:
sudo mysql_secure_installation
When you run the above command, a textual wizard allows you to secure your database server. Here are the questions he 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, so we need this scripting language on our Ubuntu system with some common PHP extensions.
sudo apt install php php-{fpm,mbstring,bcmath,xml,mysql,common,gd,cli,curl,zip}
Also enable PHP fpm to get started with FPM, if you haven’t already:
sudo systemctl enable php8.1-fpm --now
4. Install phpMyAdmin on Ubuntu 22.04
Well the only way to install phpMyAdmin is to use the APT package manager which will download and install it using Ubuntu’s repository. However, be aware that the version of phpMyadmin installed using APT will not be the most recent. This is because the long term release of Ubuntu uses extremely stable packages, so you won’t get the latest version of the software. In such a situation, we can manually download the package from phpMyadmin to configure. Let’s see how to do this.
Download the latest version of phpMyAdmin
The given command will automatically fetch and save the latest zipped file of phpMyAdmin in Tar format. Copy it and just run 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, don’t forget to create a temporary folder called ‘tmp’ in the extracted directory, otherwise it will create a warning on the phpMyAdmin interface.
sudo mkdir -p /var/www/html/phpmyadmin/tmp
5. Add Blowfish Cipher Chain
To work properly, phpMyAdmin needs the Blowfish cipher string in the configuration file for cookie authentication. However, by default there is no main configuration file as we configure phpMyAdmin manually. 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
Copy the string generated by the command above:
Now edit the Setting up phpMyAdmin file
sudo nano /var/www/html/phpmyadmin/config.inc.php
and passed in the lead:
$cfg[‘blowfish_secret’] = ‘your-key‘; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
To replace your key with the generated code.
Also scroll to the end and add this line.
$cfg['TempDir'] = '/var/www/html/phpmyadmin/tmp';
After that, save your file by pressing CTRL+Opress the Enter key, then quit the file editor- CTRL+X.
Allow Apache 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 the Apache Vhost configuration file
We don’t want to serve the phpMyAdmin UI on our root domain or IP address, therefore we use either a subdomain or a subfolder. Here we serve it in a subfolder. Therefore, create a configuration file for it.
sudo nano /etc/apache2/conf-available/phpmyadmin.conf
Copy-paste the following lines:
Alias /phpmyadmin /var/www/html/phpmyadminOptions Indexes FollowSymLinks DirectoryIndex index.php # Authorize for setupAddType 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 . # Disallow web access to directories that don't need it AuthType Basic AuthName "phpMyAdmin Setup" AuthUserFile /etc/phpmyadmin/htpasswd.setup Require valid-userOrder Deny,Allow Deny from All Order Deny,Allow Deny from All
Save the file- CTRL+O to hit Enterand exit using Ctrl+X.
Activate the new configuration:
sudo a2enconf phpmyadmin.conf
Restart the Apache web server
For the changes to apply correctly, restart the Apache web server.
sudo systemctl restart apache2
7. Access the web interface
Enter the server IP address or domain name with /phpmyadmin
folder in the browser URL to access this web database management platform.
For example:
https://server-ipaddress/phpmyadmin
Where
http://your-domain.com/phpmyadmin
Enter the MySQL database root user and his the password to login to phpMyAdmin.
To note: If you receive this notification in the footer: phpMyAdmin configuration storage is not fully configured, some extended features have been disabled. I found why. Or alternatively, go to the “Operations” tab of any database to configure it there.
Then just click on the I found why link and click the “To create” link to automatically create phpmyadmin
database.
Conclusion
This way, we can quickly install phpMyAdmin on Ubuntu 22.04 LTS Jammy to manage our MySQL or MariaDB database using a web-based graphical user interface. Due to its security, extensive functionality and comfortable operation, PhpMyAdmin is considered the standard for MySQL and MariaDB database administration. It is included in the web hosting offers of many Internet Service Providers (ISPs) and is usually part of the basic configuration of virtual dedicated and Linux servers (VPS). The most common tasks include regularly creating a backup, transferring databases to other servers, and troubleshooting technical failures.
For more information, you can visit the official documents.
Other Items:
• How to access remote MySQL database in local phpMyAdmin
• How to install phpMyAdmin on Debian 11 Bullseye (Apache)
• Install Siege benchmarking tool on Ubuntu 22.04
• How to Install PowerShell on Ubuntu 22.04 LTS