Here we are performing phpMyAdmin host on Amazon EC2 instance, It is very simple like the other Linux box configuration. We can install and configure phpMyAdmin through the download package and install it or install through yum global repositories. Here I have used the Remi repository for installing the PHPMyAdmin package. If you want to install Remi, repository on your CentOS / RHEL / Fedora Box, you can check our article Configure Additional YUM Repositories for CentOs, Red Hat, and Fedora
Here I am following install through the yum repository.
- Install phpMyAdmin rpm package through yum command by enabling remi repositories .
Steps to install phpmyadmin which I have followed
# yum --enablerepo=remi install phpMyAdmin
Dependencies Resolved ============================================================================= Package Arch Version Repository Size ============================================================================= Installing: phpMyAdmin noarch 4.7.0-1.el7.remi remi 5.0 M Installing for dependencies: dejavu-fonts-common noarch 2.33-6.el7 base 64 k dejavu-sans-fonts noarch 2.33-6.el7 base 1.4 M libtidy x86_64 0.99.0-31.20091203.el7 epel 132 k php-fedora-autoloader noarch 1.0.0-0.2.rc1.el7.remi remi 8.8 k php-google-recaptcha noarch 1.1.3-1.el7.remi remi 13 k php-phpmyadmin-motranslator noarch 3.0-1.el7.remi remi 19 k php-phpmyadmin-shapefile noarch 2.0-1.el7.remi remi 20 k php-phpmyadmin-sql-parser noarch 4.1.2-1.el7.remi remi 142 k php-phpseclib noarch 2.0.4-1.el7.remi remi 203 k php-symfony-class-loader noarch 2.8.18-1.el7.remi remi 25 k php-symfony-common noarch 2.8.18-1.el7.remi remi 130 k php-symfony-expression-language noarch 2.8.18-1.el7.remi remi 27 k php-tcpdf noarch 6.2.13-1.el7.remi remi 2.1 M php-tcpdf-dejavu-sans-fonts noarch 6.2.13-1.el7.remi remi 257 k php56w-mbstring x86_64 5.6.30-1.w7 webtatic 545 k php56w-process x86_64 5.6.30-1.w7 webtatic 45 k php56w-recode x86_64 5.6.30-1.w7 webtatic 14 k php56w-tidy x86_64 5.6.30-1.w7 webtatic 34 k recode x86_64 3.6-38.el7 base 718 k Transaction Summary ================================================================================ Install 1 Package (+19 Dependent packages) Total download size: 11 M Installed size: 49 M Is this ok [y/d/N]: y
2. Now navigate to the configuration file “/etc/httpd/conf.d/phpMyAdmin.conf” and allow to open PHPMyAdmin to access outside the local environment. Do the entry like below to phpMyadmin allow to outside your local system.
Comment the line of IP, which have a loopback address, and insert your IP with the required parameter like below.
<Directory /usr/share/phpMyAdmin/>
AddDefaultCharset UTF-8
<IfModule mod_authz_core.c>
# Apache 2.4
Require local
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
# Replace here with your IP or Network.I have replace with 172.24.254.0/24
Allow from 172.24.254.0/24
Allow from ::1
</IfModule>
</Directory>
(3) For MySQL configuration in phpMyAdmin
We have an RDS instance for Database, So we need to modify MySQL host in the config.inc.php file, which will be in the /usr/share/phpmyadmin folder, if it will not available with that name, might be it will be named as config.sample.inc.php then we need to create config.inc.php file and copy of the content of sample file into it.
vim /etc/phpMyAdmin/config.inc.php From $cfg['Servers'][$i]['host'] = 'localhost'; To $cfg['Servers'][$i]['host'] = 'xxxxxxxxxxx.rds.amazonaws.com'; //Your-RDS-Instance-Endpoint
4. Now restart your Apache webserver.
For CentOs / RHEL 5,6 :
# service httpd restart
For CentOs / RHEL 7 :
# systemctl restart httpd.service
5. Now access your phpMyAdmin through the elastic IP of your Amazon EC2 instance like below.
http://Elastic-IP-Address/phpmyadmin
You can read more articles to install and secure PHPMyAdmin at the below links.
Secure your phpMyAdmin Configuration and install the latest version
Install and Configure phpMyAdmin without YUM
That’s it! at this moment.