How To Install and Secure phpMyAdmin on a CentOS 6.4 VPS

How To Install and Secure phpMyAdmin on a CentOS 6.4 VPS
Not using CentOS 6?Choose a different version or distribution.
CentOS 6

Status: Deprecated

This article covers a version of CentOS that is no longer supported. If you are currently operating a server running CentOS 6, we highly recommend upgrading or migrating to a supported version of CentOS.

Reason: CentOS 6 reached end of life (EOL) on November 30th, 2020 and no longer receives security patches or updates. For this reason, this guide is no longer maintained.

See Instead: This guide might still be useful as a reference, but may not work on other CentOS releases. If available, we strongly recommend using a guide written for the version of CentOS you are using.

The following DigitalOcean tutorial may be of immediate interest, as it outlines installing phpMyAdmin on a CentOS 7 server:


Many websites and applications require databases to store and manage large sets of information. MySQL and MariaDB are popular database management systems because of their flexibility, power, and ubiquity.

For many users, managing databases is difficult from the command line. For those who prefer to use a web interface, phpMyAdmin is a great alternative to command driven management.

In this guide, we will cover how to install and configure phpMyAdmin on a CentOS 6.4 VPS. The procedure should be fairly similar for other versions.

Step One — Install a LAMP Stack

Before we can install phpMyAdmin, we need to install Apache, MySQL, and PHP on our server. Together, along with the underlying operating system, this is known as a LAMP stack (Linux, Apache, MySQL, PHP).

We can go ahead and install the necessary components from the default yum repositories by typing:

  1. sudo yum install httpd mysql-server php php-mysql

A web server, database server, and dynamic processing language will be installed on your server and ready to use.

Step Two — Configure the LAMP Stack

Next, we need to configure the components that we have just installed.

Start the Web Server

We can start by turning on our web server. The following command will start Apache:

  1. sudo service httpd start

Check that the server is up and running by visiting your server’s IP address in a web browser:


You should see the default CentOS Apache test page. If you do not want to use a browser, you can view the raw HTML of the page with curl:


The first part of the results should have text that looks like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <head> <title>Apache HTTP Server Test Page powered by CentOS</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <style type="text/css"> . . .

If you can see this page, the web server is up and running.

Configure MySQL

Next, we can configure MySQL, our database. Start the service by typing:

  1. sudo service mysqld start

The first thing we should do is run a simple security script, which will lock down some dangerous defaults. It will also allow us to set a database password for the root administrative user:

  1. sudo mysql_secure_installation

The first question should ask you to enter the current password for the MySQL database. Since we haven’t configured a password yet, just hit ENTER. You can then choose and confirm a password for the database immediately. Hit ENTER through all of the remaining prompts to select the default values.

You can test that your database password was set correctly by typing:

  1. mysql -u root -p

You will be prompted for the database password you just issued. After typing it in, you should be dropped into a MySQL session:

Type exit to return to your shell session:

  1. exit

Your database is ready to go now.

Step Three — Install phpMyAdmin

Now, we are ready to install the phpMyAdmin package. This software is not available in the CentOS 6 default repositories. However, it is avialable in the EPEL repos (Extra Packages for Enterprise Linux).

We can add access to the EPEL repositories to our system by typing:

  1. sudo yum install epel-release

After accepting the new repository, you can install the phpMyAdmin package by typing:

  1. sudo yum install phpmyadmin

This will install phpMyAdmin. We still must configure it though.

Step Four — Configure phpMyAdmin

For security purposes, we should lock down access to the phpMyAdmin interface to a specific IP address.

Find Your IP Address

You will need to know the IP address of the computer you plan on using to access your databases. This is a security precaution so that unauthorized people cannot connect.

Note: This is the not the IP address of your VPS, it is the IP address of your home or work computer.

You can find out how the greater web sees your IP address by visiting one of these sites in your web browser:

Compare a few different sites and make sure they all give you the same value. Write this down.

Configure Apache Files

The phpMyAdmin package installs an Apache Virtual Host file that is used to configure web access. Open the file with the following command:

  1. sudo nano /etc/httpd/conf.d/phpMyAdmin.conf

By default, this configuration only allows access from the same computer that is hosting the software. Because the databases, web server, and administration software are hosted on a VPS instead of your home computer, we will have to adjust these values.

This is where the IP information about your home computer comes in handy. We will change every reference to with the IP address you found.

There should be four locations that you need to change:

. . .
Require ip your_workstation_IP_address
. . .
Allow from your_workstation_IP_address
. . .
Require ip your_workstation_IP_address
. . .
Allow from your_workstation_IP_address
. . .

Save and close the file.

You need to restart the server with the following command:

  1. sudo service httpd restart

Step Five — See the Results!

Your interface should now be configured and ready to access.

Point your web browser to your VPS IP address followed by “/phpmyadmin”


You will be asked to log in. Use the user root and the password that you selected during the MySQL configuration stage.

<img src=“https://assets.digitalocean.com/articles/cent_phpmyadmin/login.png” alt=“phpMyAdmin login prompt” />

After you provide the requested credentials, you will have access to the phpMyAdmin interface:

<img src=“https://assets.digitalocean.com/articles/cent_phpmyadmin/main_screen.png” alt=“phpMyAdmin main interface screen” />

Congratulations, you can now begin managing your database software from the web interface!

<div class=“author”>By Justin Ellingwood</div>

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

What do you suggest for those of us without a static ip address at home? My ISP changes my ip address daily (which is a serious PITA) so I also receive a 403 as I am unable to complete the last section.

Kamal Nasser
DigitalOcean Employee
DigitalOcean Employee badge
October 16, 2013

@Blick: Yes, it would stop working since it’s locked down to your IP address at a specific point in time so if it changes it doesn’t get automatically updated on your droplet.

I have dynamic ip at home, is it a matter after my ip was schanged?

i could not see phpmyadmin so i edit every reference to with the IP address and i was successfull but now i cant use putty and i see -bash command not found for every command , i wanted to install wordpress and i cant download it because is comand: -bash: wget: command not found

Followed the installing LAMP tutorial, all success. Followed this tutorial trying to get phpmyadmin up and running, all goes well until I try to connect … I get this:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, root@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Today’s error_log reads:

[Fri Nov 27 10:37:05 2015] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Fri Nov 27 10:37:05 2015] [notice] Digest: generating secret for digest authentication ...
[Fri Nov 27 10:37:05 2015] [notice] Digest: done
[Fri Nov 27 10:37:05 2015] [notice] Apache/2.2.15 (Unix) DAV/2 PHP/5.3.3 configured -- resuming normal operations

Im stumped. The server is acting like no files exist. Any help/advice?

Pastebin link to contents of my /etc/httpd/conf.d/phpMyAdmin.conf file: http://pastebin.com/ijqQjUdQ

So I followed all these steps. When I put http:mywebsite.com/phpMyAdmin/ I get a blank screen. when I look at my source, there are empty tags. I have sftped the site and see all the files are there and in the appropriate place. My IP address is in the .htaccess doc. what could I be missing?

This is what i get after installing using the above steps "Not Found

The requested URL /phpmyadmin was not found on this server.

Apache/2.2.15 (CentOS) Server at xxx.xxx.xx.xx Port 80"

I feel like killing myself, have tried installing multiple times and been destroying and recreating droplets like crazy. Any help please?

When I run sudo service httpd start it returns httpd: unrecognized service Any recommendations?

Httpd: unrecognized service I had many problems with this installation and managed to fix most of them

so I inherited this site. I went into /ect/httpd/conf.d/phpMyAdmin.conf and added Allow from my ip address

I found the phpMyAdmin folder in my var/www/html folder. inside the phpMyAdmin folder there is a .htaccess. I added Allow from myip address and restarted the service. When I enter URL/phpMyAdmin/ I get a blank page. Any Ideas?

I’m tring to access the database. When ever I try to use mysqldump I get a table error. Tried fixing the tables but get another error. I need to do a mysql update but need to backup the database before I do that.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel