Skip to content
Home » Linux » How to Install phpMyAdmin on CentOS 6.4 by Example

How to Install phpMyAdmin on CentOS 6.4 by Example

First of all, you must ensure your LAMP has been installed and is running well. If you are looking for LAMP solutions, you may refer to the following posts:

Now, let's see how we install phpMyAdmin well.

First of all, search for a proper phpMyAdmin package.

[root@localhost ~]# yum --enablerepo=remi info phpmyadmin
...

If everything is OK, then install the package.

[root@localhost ~]# yum --enablerepo=remi install phpmyadmin
...

You can see phpmyadmin requires a lot of extra PHP modules to run with.

Try it on local browser.

http://localhost/phpmyadmin/

It would be no problem to show the login page on localhost.

But if you access it (e.g. http://www.example.com/phpmyadmin) from a remote client, you will see the following error:

Forbidden
You don't have permission to access /phpmyadmin/ on this server.

Apache/2.2.25 (CentOS) Server at www.example.com Port 80

To conquer the problem, you should modify the configuration file of phpmyadmin and make httpd allowed to be accessed. For example, we would like to make a client from 10.1.2.59 allowed to access phpmyadmin. You can add your ip address range that is marked as yellow below. It depends on what version of httpd you're using.

[root@localhost ~]# vi /etc/httpd/conf.d/phpMyAdmin.conf
...
<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require ip 127.0.0.1 10.73.12.0/24
       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 10.73.12.0/24
     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 10.73.12.0/24
       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 10.73.12.0/24
     Allow from ::1
   </IfModule>
</Directory>
...

Then restart httpd

[root@localhost ~]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

Now, connect it again from the allowed client. It should work now.

Leave a Reply

Your email address will not be published. Required fields are marked *