PhpMyAdmin is a free, open-source, web-based database management application for MySQL and MariaDB. Users are provided with a graphical interface that eliminates the need for them to use the command line to manage and administer their databases.
This brief guide will teach you how to install and configure the phpMyAdmin with Apache on Ubuntu.
Before you can configure the phpMyAdmin with Apache, you’d need to find details of different packages on your system and install them if they aren’t preinstalled. Before installing packages, update and refresh your Ubuntu repositories.
1.1 Update System
First, open the terminal and update the system using the following command.
sudo apt update
1.2. Install LAMP stack
Make sure the LAMP stack is installed on your system.
1.2.a Check the Status of the Apache2 Service
You’ll need to find if the apache service is running on your system using this command.
sudo systemctl status apache2
1.2.b. Make sure the MySQL /MariaDB service is running
Now check the status of your MySQL or the MariaDB server using this command.
sudo systemctl status mariadb
1.2.c Make sure PHP installed
You’ll need to install the latest edition of the PHP & to check if it has been installed on your system, use this command:
1.3. Install PHP Extensions for phpMyAdmin
Now, install all the PHP extensions required by the phpMyAdmin using the following command:
sudo apt install php php-fpm php-mbstring php-bcmath php-xml php-mysql php-common php-gd php-cli php-curl php-zip -y
1.4. Enable php-fpm to start with FPM
Now enable the php-fpm service to use its features.
sudo systemctl enable php8.1-fpm
Download phpMyAdmin on the System:
Now download the latest version of the phpMyAdmin DB administration tool. First, go to the following directory on your system:
Now use the following command to see the contents of the current directory:
Now download the latest version of the phpMyAdmin from the official website using the following command on the terminal:
sudo wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz
Use the following command to check if the file has been downloaded:
Now extract the downloaded file through this command:
sudo tar -xvf phpMyAdmin-latest-all-langauges.tar.gz
“phpMyAdmin-latest-all-langauges.tar.gz” is the name of the downloaded file.
After that, rename the extracted folder using the following command:
sudo mv phpMyAdmin-5.2.0-all-languages phpmyadmin
“phpMyAdmin-5.2.0-all-languages” is the name of the extracted folder in the above command, and “phpmyadmin” is the name we have given to it.
In this step, we’ll cover the configuration of the phpMyAdmin tool on our system.
3.1 Go to phpmyadmin Directory
First, go to the phpmyadmin directory using the following commands:
3.2 Create A New Folder for phpMyAdmin Temp Files
Now create a tmp-named folder for the temporary files of the phpMyAdmin.
sudo mkdir tmp
3.3 Rename The Configuration File
Rename the config.sample.inc.php file to config.inc.php by using the following command:
sudo mv config.sample.inc.php config.inc.php
3.4 Generate A 32-bit String
Now, generate a 32-bit secret string that is needed for cookie-based authentication. Copy it after generating.
sudo openssl rand -base64 22
3.5. Open & Edit Configuration File
Now, open and edit the configuration file of PHP by using the following command:
sudo vim config.inc.php
3.5.a Add the Secret String
Now, paste the secret string against the [blowfish_secret] generator as a password to use phpMyAdmin.
3.5.b Add Content at the End of the File
Then go to the end of the file to add the following code snippet:
$cfg['TempDir'] = '/var/www/html/phpmyadmin/tmp';
Now save and exit the file by pressing Esc Shift and then using the following command:
3.6. Change Ownership
After that, change the writing privileges on the phpmyadmin directory using the following command:
sudo chown -R www-data:www-data phpmyadmin/
3.7. Create Apache vHost Configuration File
Now you’d need to create an apache vHost configuration file for the phpMyAdmin called “phpmyadmin.conf” by using the following command:
sudo vim /etc/apache2/conf-available/phpmyadmin.conf
3.7.a Add Content
Now add the following code snippet on the terminal:
Alias /phpmyadmin /var/www/html/phpmyadmin
Options Indexes FollowSymLinks
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 .
# Authorize for setup
AuthName "phpmyadmin Setup"
# Disallow web access to directories that don't need it
Deny from All
Deny from All
3.7.b Save and exit file
Now save and exit the file by pressing the Esc Shift keys and then using the following command:
3.8. Restart Apache Server
Restart the apache service using the following command:
sudo systemctl restart apache2
Access phpMyAdmin Via the web interface:
Now we’ll set up the front end of the phpMyAdmin tool via the web interface using any browser.
4.1 Check the IP of the System
4.2 Access phpMyAdmin Via Address:
Now open any browser and access the phpMyAdmin Administrative tool’s web interface using your server’s IP.
4.3 Login phpMyAdmin Tool
Now use your credentials to log in to the Database Management tool. Use the root as a username and Pass_of_root as a password.