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.
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 –– Add EPEL Repositories
cd ~ wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Note that even though this file is coming from the 64 bit repository, it is architecture agnostic, meaning it will work for either 32 bit or 64 bit installations.
This will download the package into our home directory. Install it by typing:
sudo rpm -ivh epel-release*
Your installation now is aware of the EPEL repositories and will query it for packages.
We can check this by typing:
. . . repo id repo name status base CentOS-6 - Base 6381 epel Extra Packages for Enterprise Linux 6 - x86_64 9788 extras CentOS-6 - Extras 13 updates CentOS-6 - Updates 1336 repolist: 17518
As you can see, the EPEL repo is present.
Step Two –– Download and Configure MySQL
To install it, simply type:
Upon installation, MySQL does not start automatically. We can start it manually by typing:
sudo service mysqld start
We can configure some necessary directory structures and create some management system tables with the following command:
Afterwards, we can harden our installation a bit by changing some dangerous defaults. There is a provided script that will walk us through this:
You will be asked a number of questions:
- Enter current password for root: press Enter
- Set root password? Y
- New password: Type an administrative password here
- Re-enter new password: Confirm the password
- Remove anonymous users? Y
- Disallow root login remotely? Y
- Remove test database and access to it? Y
- Reload privilege tables now? Y
Your MySQL installation should be up and running. Test that you can log in with the password you set by typing:
mysql -u root -p
Supply the password you have just set. You will be given a MySQL prompt.
exit to return to the shell prompt:
Step Three –– Download phpMyAdmin
sudo yum install phpmyadmin
You may be asked to confirm once or twice, and then the packages will be downloaded and installed.
Step Four –– Configure phpMyAdmin
Find Your IP Address
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
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
127.0.0.1 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 start the server with the following command:
sudo service httpd start
Step Five –– See the Results!
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.