How to install and configure phpMyAdmin on Ubuntu Linux

How to install and configure phpMyAdmin on Ubuntu Linux

In this article, we are going to learn how to install and configure phpMyAdmin in Ubuntu Linux. phpMyadmin is the best web-based client to access MySQL servers. This client is available for free to download and install on the server.

You can use this tool on any server running Apache and PHP. It should be noted that phpMyAdmin is written in PHP and its current version is compatible with PHP 7.1 and MySQL 5.5 or MariaDB 5.5 and newer.

Step 1) Install Apache and PHP

Here we assume that you have already installed MySQL server on Ubuntu system. Therefore, we install only other necessary packages. These packages will be required to launch and access phpMyAdmin.

1
2
3
sudo apt install apache2 wget unzip
sudo apt install php php-zip php-json php-mbstring php-mysql

After completing the installation, activate and run the Apache web server.

1
2
3
systemctl enable apache2
systemctl start apache2

Step 2) Install phpMyAdmin on Linux Ubuntu 20.04

Of course, phpMyAdmin is also available in default package sources, but in many cases, these sources contain old versions. In this tutorial, you will get the latest version of phpMyAdmin and set it up in the system.

Now your system is ready to install phpMyAdmin. You can download the latest archive of phpMyAdmin from its official page or use the following commands to download phpMyAdmin 5.0.2 on your system.

After receiving the archive, extract it and move it to the appropriate place.

1
2
3
4
5
wget https://files.phpmyadmin.net/phpMyAdmin/5.0.2/phpMyAdmin-5.0.2-all-languages.zip
unzip phpMyAdmin-5.0.2-all-languages.zip
mv phpMyAdmin-5.0.2-all-languages /usr/share/phpmyadmin

Then create the tmp directory and set the necessary permissions.

1
2
3
4
5
mkdir /usr/share/phpmyadmin/tmp
chown -R www-data:www-data /usr/share/phpmyadmin
chmod 777 /usr/share/phpmyadmin/tmp

Step 3) phpMyAdmin settings in Ubuntu Linux

Now it’s time to set up the web server to serve phpMyAdmin on the network. Create an Apache configuration file for phpMyAdmin and edit it in a text editor.

1
vi /etc/apache/conf-enabled/phpmyadmin.conf

Add the following content to the file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin
<Directory /usr/share/phpmyadmin/>
AddDefaultCharset UTF-8
<IfModule mod_authz_core.c>
<RequireAny>
Require all granted
</RequireAny>
</IfModule>
</Directory>
<Directory /usr/share/phpmyadmin/setup/>
<IfModule mod_authz_core.c>
<RequireAny>
Require all granted
</RequireAny>
</IfModule>
</Directory>

Save the file and close it.

After you have made all the changes, be sure to restart the Apache server to restore all the settings.

1
2
3
sudo a2enconf phpmyadmin
sudo systemctl restart apache2

Step 4) FirewallD settings

In a system that has an active firewall, there is a need to allow the HTTP service through the firewall. You can open a port for the web server in the firewall using the following commands.

1
2
3
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload

Step 5) Access phpMyAdmin in Ubuntu

The job is done and you have installed phpMyAdmin on your Ubuntu Linux system. Now it’s time to access phpMyAdmin with server IP address or domain name.

1
http://your-server-ip-domain/phpmyadmin

Replace your-server-ip-domain with localhost (for local systems) or system IP address for remote systems. Here the DNS is updated and dbhost.tecadmin.net is pointed to the server IP address.

How to install phpmyadmin on Ubuntu 20.04

Log in to the command line with the username and password to access MySQL.

Setting up phpmyadmin – Ubuntu 20.04

Conclusion

In this article, you learned how to set up phpMyAdmin in the Ubuntu system and you have successfully set it up. However, due to security considerations, you should disable root user login for phpMyAdmin.

support hosting100