How can we restrict ip based access to phpmyadmin directory

I was working on this in last week and I came to know following solution. There can be other ways too , but I am not sure. So I am just explaining the way I did it for my site.

1. You can edit phpMyAdmin.conf (located at /etc/httpd/conf.d/) file in vi editor.
2. Following code block should be there.

< directory /var/www/phpMyAdmin >
DirectoryIndex index.php
Options Includes ExecCGI
AllowOverride None
Order deny,allow
Allow from all
< / Directory >

3. Add new line "Allow from ip.ip.ip.ip", check code below.

< directory /var/www/phpMyAdmin >
DirectoryIndex index.php
Options Includes ExecCGI
AllowOverride None
Order deny,allow
Allow from ip.ip.ip.ip
Allow from all
< / Directory >

please put your comments if you have any suggestions or doubts about this implementation.

Editing phpmyadmin.conf to restrict access change alias

If you want to change alias of your phpmyadmin directory then you just need to edit your phpmyadmin.conf file and update following line.

- vi phpmyadmin.conf (if you use windows then just use any editor. I like linux)
- Alias /aliasname /var/www/phpmyadmin
- done

vi phpmyadmin.conf - Will open phpmyadmin.conf file in vi editor.
aliasname - you can set any new string here

So next time you can hit http://localhost/aliasname instead of http://localhost/phpmyadmin.

Related Questions?
How to give ip based restriction to phpmyadmin directory.

Share this post with your friends