Install and setup PHPMYADMIN MySQL software on CentOS server running Apache (LAMP) – I keep figuring what’s the next tutorials should be until then I contacted by one of my readers asking me how to install PhpMyAdmin. So here it is the tutorial to guide you how to install PhpMyAdmin on a CentOS server running LAMP stack (Linux, Apache, MySQL, PHP). However I assume by following this tutorial you have already had a server with LAMP stack installed, configured and running properly. Otherwise simply follow my previous guide how to set it up or here for installing LAMP with PHP 5.5 and MySQL v5.5.32.
What you’ll need?
- This guide is done in a CentOS 6.4 x86_64 VPS (as always by DigitalOcean). Hence, you’ll need a CentOS server. However you can still follow the tutorial by adjusting some commands if you are using any other Linux Distros.
- I also assumed you knew already how to use Putty or Terminal to SSH-ing a server.
- I believe you knew –at least part of– most common Unix commands used to manage an unmanaged server.
How To Install PHPMYADMIN
Step 1 – Login to your server and follow my previous guide about Basic setup for CentOS before you build a live web server. You may and may not follow that tutorial but if you followed, it will give you some basic security tweak to your server.
Before you proceed to the next steps, it is better to explain that all commands in this tutorial are written without the “sudo” prefix. However if you disabled root login and you logged in using another username with root privilege, you can add the “sudo” prefix all by your self. Alternatively you can simply type su, hit Enter and type in your password twice to switch login as root. You may also need to type this command to go to the root directory:
Step 2 – Install PhpMyAdmin via yum using this command:
yum install phpmyadmin -y
p.s: Optional – You better firstly issue “yum update -y” and “yum upgrade -y” before running above command just to make sure yum is updated.
Step 3 – So the you’ve installed PhpMyAdmin but you may also firstly need to edit Apache configuration before using it. Edit phpmyadmin.conf file:
Step 4 – Its main content will look like this;
# Web application to manage MySQL
Deny from all
Allow from 127.0.0.1
Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin
Alias /mysqladmin /usr/share/phpmyadmin
Now you’ll need to comment (add # symbol) starting from <Directory “/usr/share/phpmyadmin”> till the </Directory> line. This is aimed to change the Apache configuration so that phpMyAdmin allows connections not just from localhost. At the end it should look like this:
Now save (Control+O) then exit Nano editor (Control+X).
Step 5 – This step is optional, changing how the way you login to PhpMyAdmin from “cookie”-based authentication to “http”. Edit PhpMyAdmin configuration file (config.inc.php):
then look for the line that says:
$cfg['Servers'][$i]['auth_type'] = 'cookie';
now replace ‘cookie’ with ‘http’
$cfg['Servers'][$i]['auth_type'] = 'http';
Once done, save it then exit Nano editor.
Step 6 – Finally, restart Apache and MySQL:
service httpd restart
service mysqld restart
Access and Login PHPMYADMIN
You can access PhpMyAdmin in your browser via:
Your browser should directly prompt you to enter username and password. You can simply use root as username and enter its password. Remember, the password is the MySQL root password not your server root password. You can also use any other MySQL username and password if you have created one. Read top most common MySQL basic commands.