How to Install and Configure phpMyAdmin on Ubuntu 14.04

phpMyAdmin is an open source tool used for the administration of MySQL. In addition to offering the capability to perform administration tasks such as creating, editing, or deleting databases, and managing users and permissions, phpMyAdmin provides a graphical user interface to do all of these tasks and more.

Pre-Flight Check

  • These instructions are intended specifically for installing phpMyAdmin on Ubuntu 14.04 LTS.
  • I’ll be working from a Liquid Web Core Managed Ubuntu 14.04 LTS server, and I’ll be logged in as root.
  • A LAMP, Linux, Apache, MySQL, and PHP, must be installed and running on your server. If you’re working from a Liquid Web Core Managed Ubuntu 14.04 LTS server as I am, then the LAMP stack is already installed!

Step 1: Install phpMyAdmin

First, you’ll follow a simple best practice: ensuring the list of available packages is up to date before installing anything new.

apt-get -y update

Then it’s a matter of just running one command for installation via apt-get:

apt-get -y install phpmyadmin

 

Step 2: Basic Configuration

As the installation runs you’ll be asked a few simple questions regarding the basic configuration of phpMyAdmin.

At the first screen, select apache2 by using the spacebar, then hit enter to continue.

How To Install and Secure phpMyAdmin on Ubuntu 12.04

At the second screen, which asks “configure the database for phpMyAdmin with dbconfig-common?”, select Yes, then hit enter to continue.

How to Install and Secure phpMyAdmin on Ubuntu 12.04

In this third screen enter your administrative password this is also the MySQL root (admin) user password, hit enter to continue.

How to Install and Secure phpMyAdmin on Ubuntu 12.04
Finally, at the fourth screen set the password you’ll use to log into phpMyAdmin, hit enter to continue, and confirm your password.How to Install and Secure phpMyAdmin on Ubuntu 12.04

 

Step 3: Finish the Configuration of Apache

For a refresher on editing files with vim see: New User Tutorial: Overview of the Vim Text Editor

vim /etc/apache2/apache2.conf

 

Add the following to the bottom of the file:

# phpMyAdmin Configuration
Include /etc/phpmyadmin/apache.conf

 

Then exit and save the file with the command :wq.

Restart Apache 2 with the following command:

service apache2 restart

 

Verify that phpMyAdmin is working by visiting the_IP_of_your_server/phpmyadmin. For example: http://127.0.0.1/phpmyadmin

Note
By default, the username is phpMyAdmin and the password will be the one set in the very last screen of Step 2.

Like all applications and software that are popular, they expose points to exploit.  You can add a layer of security to your phpMyAdmin installation to prevent any unwanted guests.

Securing with Pop Up Login

Step 1: Edit Apache for .htaccess Overrides

vim /etc/apache2/conf-available/phpmyadmin.conf

Insert the code below into the file between the <Directory> </Directory> tags. , afterward save and exit by typing :wq hitting Enter

<Directory /usr/share/phpmyadmin>
Options FollowSymLinks
DirectoryIndex index.php
AllowOverride All
</Directory>

 

Step 2: Create the .htaccess File

/usr/share/phpmyadmin/.htaccess

Paste in the code below:
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/phpmyadmin/.htpasswd
Require valid-user

 

Step 3: Create the .htpasswd File and Username

Pasting the code below conveniently makes a .htpasswd file while simultaneously creating a user.  Replace the username in this example with the username of your choice. I’m going to choose the username, tom, which we will use in step 4.

htpasswd -c /etc/phpmyadmin/.htpasswd username

 If we read this file we will find that it has added this user and has encrypted their password:

~# cat /etc/phpmyadmin/.htpasswd
tom:$apr1$fi4fis3.$oDVeDWxsp5eDhk.gc/DT991

 

Step 4: Verify Pop-Up Functionality

Visit http://yourhostname.com/phpmyadmin/  (replacing yourhostname.com with your server’s hostname or IP) to display a pop-up box where I will enter my username, tom, that I created in step 3.

Pop Up Window

Securing by Changing URL to phpMyAdmin

Open the /etc/phpmyadmin/apache.conf file:

vim /etc/phpmyadmin/apache.conf

Comment out the line Alias /phpmyadmin /usr/share/phpmyadmin with a # (as pictured below) and add in your the new URL you want to access your phpMyAdmin instance.


#Alias /phpmyadmin /usr/share/phpmyadmin
Alias /mynewurl /usr/share/phpmyadmin

Hit the ESC button and type :wq to save and quit.

Be Sociable, Share!
Here's 75 % off, Launch a New VPS Today. Find out why 30,000 customers have chosen our Best-in-Class Performance & 24x7 Heroic Support