Tuesday, September 30, 2014

CentOS 7 - How to install phpmyadmin (Apache)

As you installed CentOS 7 you might realize that there are some notable changes. Shift from MySQL to MariaDB is one of thoese changes. MaridDB is an enhanced, drop-in replacement for MySQL. MariaDB strives to be the logical choice for database professionals looking for a robust, scalable, and reliable SQL server. For a list of "MariaDB vs MySQL", go to this link (https://mariadb.com/kb/en/mariadb/mariadb-vs-mysql-features/). In this blog I will show you how to install phpmyadmin in CentOS 7. phpmyadmin is a webbased SQl DB management interface.

To install phpmyadmin, you need additional repository - EPEL (Extra packages for enterprise Linux). You can find the latest repo file from this link: http://mirror.its.dal.ca/pub/epel/beta/7/x86_64/

The EPEL file you are looking for is called "epel-release-7-x.noarch.rpm", in my example, I use "epel-release-7-1.noarch.rpm":

Download the rpm file:
# cd ~
# wget http://download.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm

Install and configure system to use epel repo:
# rpm -ivh epel-release-7-0.2.noarch.rpm

Install phpmyadmin package:
# yum install phpmyadmin

Configure phpmyadmin:
The phpmyadmin configuration file for Apache is "/etc/httpd/conf.d/phpMyAdmin.conf". Open this file with your favourite editor, it looks like:
# Allows only localhost by default
#
# But allowing phpMyAdmin to anyone other than localhost should be considered
# dangerous unless properly secured by SSL
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin

<Directory /usr/share/phpMyAdmin/>
   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require ip 127.0.0.1
       Require ip ::1
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1
     Allow from ::1
   </IfModule>
</Directory>

By default, it denies access from any IP instead of localhost. If you want to allow other IPs to access it, you have to comment out "Require ip 127.0.0.1", "Require ip ::1" for both Apache 2.2 and 2.4. You can use "Require all granted" if you want to allow access from anywhere (this is dangerous!). Example:
   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
     #  Require ip 127.0.0.1
     #  Require ip ::1
        Require all granted
     </RequireAny>
   </IfModule>

When you done editing, restart the Apache server and you are good to go:
# systemctl restart httpd.service

Go to
http://server_domain_or_IP/phpMyAdmin

No comments: