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.
- 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.
At the second screen, which asks “configure the database for phpMyAdmin with dbconfig-common?”, select Yes, then hit enter to continue.
In this third screen enter your administrative password this is also the MySQL root (admin) user password, hit enter to continue.
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
Add the following to the bottom of the file:
# phpMyAdmin Configuration
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
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
Insert the code below into the file between the <Directory> </Directory> tags. , afterward save and exit by typing :wq hitting Enter
Step 2: Create the .htaccess File
Paste in the code below:
AuthName "Restricted Files"
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
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.
Securing by Changing URL to phpMyAdmin
Open the /etc/phpmyadmin/apache.conf file:
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.