Install phpMyAdmin on CentOS 7 for PHP 7

Install phpMyAdmin on CentOS 7 for PHP 7

In a previous article, we installed lamp stack on CentOS 7. Today will install phpMyAdmin to work with PHP 7.

Important: Epel repository provides a phpMyAdmin package for PHP 5, But it is not compatible with PHP 7. For PHP 7, we need to manually download and setup phpMyAdmin web interface.

Download phpMyAdmin for CentOS 7

You can get the download link to the latest version of phpMyAdmin from following URL https://www.phpmyadmin.net/downloads/.

To begin, log in as root and change into the /usr/share directory:

cd /usr/share

Download phpMyAdmin package:

curl -O https://files.phpmyadmin.net/phpMyAdmin/4.7.5/phpMyAdmin-4.7.5-all-languages.tar.gz

Extract tar file:

tar -zxvf phpMyAdmin-4.7.5-all-languages.tar.gz

Rename the extracted folder:

mv phpMyAdmin-4.7.5-all-languages phpmyadmin

Create apache configuration file:

vim /etc/httpd/conf.d/phpmyadmin.conf

Add following configuration:

Alias /phpMyAdmin /usr/share/phpmyadmin
Alias /phpmyadmin /usr/share/phpmyadmin

<Directory /usr/share/phpmyadmin/>
    AddDefaultCharset UTF-8

    <IfModule mod_authz_core.c>
      # Apache 2.4
      <RequireAny>
        Require all granted
        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>

<Directory /usr/share/phpmyadmin/setup/>
    <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>

# These directories do not require access over HTTP - taken from the original
# phpmyadmin upstream tarball
#
<Directory /usr/share/phpmyadmin/libraries/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>

<Directory /usr/share/phpmyadmin/setup/lib/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>

<Directory /usr/share/phpmyadmin/setup/frames/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>

Save the file and restart the httpd server:

systemctl restart httpd

And we are done!! To open phpMyAdmin type http://server_ip/phpmyadmin and You should see the login page.

If you are getting the error message "The configuration file now needs a secret passphrase (blowfish_secret)", Then do the steps described in this link to solve the problem.