How to Install and Secure phpMyAdmin in Ubuntu 14.04

Jose Velazquez
by Atlantic.Net (71posts) under HIPAA Compliant Dedicated Server Hosting
0 Comments
Verified and Tested 01/31/2015

Introduction

This document will help you install phpMyAdmin and describe some basic steps to take in order to secure it.

Prerequisites

You need an Ubuntu 14.04 server that is configured with a static IP address.

You will also need to have LAMP (Linux, Apache, MySQL and PHP) installed on the server.

Installing phpMyAdmin

Install phpMyAdmin

sudo apt-get install phpmyadmin

phpMyAdmin is now installed on your server. Now we begin the Apache configuration.

 

Setup phpMyAdmin under Apache, edit the apache2.conf file.

sudo nano /etc/apache2/apache2.conf

Add the following code to the bottom of the apache2.conf file.

Include /etc/phpmyadmin/apache.conf
Add your config file for phpmyadmin

apache2.conf

Save your changes by pressing Ctrl + X then Y to accept.

Restart Apache.

sudo service apache2 restart

Verify that your installation works, type the following link in your browser http://YOURIP/myphpadmin

(Log in with the username and password that was created during the installation)

Securing myPHPAdmin

Setup security for phpMyAdmin, edit the apache.conf file:

sudo nano /etc/phpmyadmin/apache.conf

Locate the <Directory /usr/share/phpmyadmin> and add the following rule under DirectoryIndex index.php

AllowOverride All

 

Add directive AllowOveride All to apache.conf

apache.conf

Save your changes by pressing Ctrl + X then Y to accept.

Create the .htaccess file that will handle the authentication.

sudo nano /usr/share/phpmyadmin/.htaccess

Paste the following text in the file:

AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/apache2/.phpmyadmin.htpasswd
Require valid-user
Sample: .htacess

Sample: .htacess

Save your changes by pressing Ctrl + X then Y to accept.

Create a user and password that you would like to use for security access by pasting the following code. Then you will enter and re enter your password. (Note:Replace username with the actual user that you want to create. I will be using admin).

sudo htpasswd -c /etc/apache2/.phpmyadmin.htpasswd username

Restart Apache.

sudo service apache2 restart

Verify that everything works by typing the following link in your browser http://YOURIP/myphpadmin and typing your security username and password

Sample Login Prompt

Sample Login Prompt

Congratulations! You have just installed and secured phpMyAdmin on your server. Thank you for following along in this How-To and feel free to check back with us for any new updates.

Atlantic.Net

Since 1995, Atlantic.Net has been providing internet services to customers, including managed, cloud and dedicated hosting.   In 20+ years of service, our solutions have been focused on providing the very best in web solutions to our valued customers!

Not sure what you need?

Get a free consultation today!

New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2323 Bryan Street,

Dallas, Texas 75201

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources

We use cookies for advertising, social media and analytics purposes. Read about how we use cookies in our updated Privacy Policy. If you continue to use this site, you consent to our use of cookies and our Privacy Policy.