If you are not adept at managing your MySQL database on a terminal, phpMyAdmin provides a graphical interface that simplifies your database administration. phpMyAdmin is a free and open-source front-end PHP-based control panel that allows you to manage your MySQL databases & users, run complex queries, import and export database backups, review SQL activity, and adjust a myriad of other settings pertaining to your MySQL database. In this tutorial, you will learn how you can install phpMyAdmin on Ubuntu 18.04.

Prerequisites

Before we proceed to install phpMyAdmin, ensure you have the following installed.

  1. LAMP stack – Linux Apache MySQL PHP. You can follow steps in this tutorial to install LAMP stack on Ubuntu.
  2. MySQL 5.0.1 or later
  3. PHP 5.2.0 or later

To check MySQL version, log in to the MySQL database as shown.

Provide and password, and thereafter, the details, including the version of MySQL, will be displayed

Output

check-mysql-version

To check the PHP version, execute the command.

Output

check-PHP-version

Install phpMyAdmin on Ubuntu 18.04

phpMyAdmin is available and kept up-to-date in Ubuntu’s repositories. This is therefore the recommended way of installing phpMyAdmin.

Step 1: Update the System

Firstly, update the system repositories using the command below

Output

update-system-repositories-1

Step 2: Install and configure phpMyAdmin

To install phpMyAdmin, run the command

Output

apt-install-phpmyadmin

As the installation process proceeds, you will be presented with the screen below requiring you to choose the web server.

Hit on the SPACEBAR button to highlight ‘Apache‘.

Hit the TAB button which moves the cursor to the OK button

Next, hit ENTER.

web-server-to-reconfigure

The installation will continue for a few seconds and later bring you to this screen.

configure-database-fro-phpmyadmin

Select ‘Yes‘ and hit ENTER

The system will thereafter prompt you for the phpMyAdmin password. Provide the password.

MySQL-password

Confirm the password in the next screen

password-confirmation

After the installation is complete, you can find the phpMyAdmin configuration in the /etc/apache2/conf-enabled/phpmyadmin.conf file

Finally, restart Apache web server to effect the changes

Step 3: Accessing phpMyAdmin panel

To log in to phpMyAdmin, fire up your browser and browse your server’s URL as shown

https://server-ip/phpmyadmin/

Be sure to log in using the root user and corresponding password

phpmyadmin-login-page

Hit “Go” To access the phpMyAdmin dashboard

Securing phpMyAdmin

Before we wrap up this tutorial, we need to pay heed to some security considerations when using phpMyAdmin.

phpMyAdmin communicates directly with MySQL database and uses the same authentication credentials that are used when accessing MySQL. For these 2 reasons, phpMyAdmin becomes a potential target for hackers. Therefore, running phpMyAdmin over plain HTTP connection is advised against. One of the ways of securing our phpMyAdmin instance is by placing a gateway in front of the platform.

We will use Apache’s .htaccess for authorization and authentication.

Configure Apache to allow .htaccess overrides

To begin with, we are going to enable the .htaccess file overrides function by editing the Apache configuration file in /etc/apache2/conf-available/phpmyadmin.conf.

We will add the AllowOverride All directive in the section of the Apache configuration file as shown

Appen-AllowOverride-All-attribute

Save and exit the text editor.

To effect the changes, restart the Apache web server

Create a .htaccess file

Having enabled the .htaccess use for our phpMyAdmin application, let’s create the .htaccess file for security implementation.

For it to be a success, we are going to create the file within phpMyAdmin directory

Add the following information to the file

Let’s have a look at some of the terminologies in the file

AuthType Basic: The attribute specifies the type of authentication to be implemented. This implements a password authentication using a password file.

AuthName: This attribute sets the message for the authentication dialog box.

AuthUserFile: This defines the location of the password file to be used for the authentication.

Require valid-user: This attribute specifies that only authenticated users are allowed to access phpMyAdmin application. This keeps any unauthorized users from logging in.

Create a .htpasswd file for authentication

The final stage will be to create a .htpasswd file for authentication. We are going to create it within the /etc/phpmyadmin/.htpasswd file like we specified earlier in the /usr/share/phpmyadmin/.htaccess file.

Thereafter, you will be prompted to create a password and later confirm for the user that you are creating.

In the output below, we have created user ‘spikey

configure-htaccess-username-and-password

You can add an additional user without the -c flag as shown

Now, let’s access phpMyAdmin via the browser. Notice the pop-up authentication dialog box.

Use the credentials you defined using the htpasswd command and click on ‘Sign In’.

https://server-ip/phpmyadmin/

sign-in-using-htaccess-file

After logging in, you will be directed to the phpMyAdmin dashboard as before.

Wrapping up

This concludes our tutorial on how you can install phpMyAdmin on Ubuntu 18.04 with additional security. phpMyAdmin provides a seamless and efficient way of managing your databases, users and other aspects of your databases and tables.

By admin

Leave a Reply

%d bloggers like this: