I have noticed that there are strange requests to my website trying to find phpmyadmin, like
/phpmyadmin/
/pma/
etc.
Now I have installed PMA on Ubuntu via apt and would like to access it via webaddress different from /phpmyadmin/. What can I do to change it?
Thanks
Update
For Ubuntu 9.10 and Apache2, the corresponding setting is located in the file /etc/apache2/conf.d/phpmyadmin.conf
which is a link to /etc/phpmyadmin/apache.conf
. The file contains
Alias /phpmyadmin /usr/share/phpmyadmin
where the first /phpmyadmin
should be changed to something different if one wants to avoid the unnecessary activity, e.g.:
Alias /secret /usr/share/phpmyadmin
In newer versions of phpMyAdmin access permissions for user-names + ip-addresses can be set up inside the phpMyAdmin's config.inc.php file. This is a much better and more robust method of restricting access (over hard-coding URLs and IP addresses into Apache's httpd.conf).
Here is a full example of how to switch to white-listing all users (no one outside this list will be allowed access), and also how to restrict user root to the local system and network only.
Source: How to Install and Secure phpMyAdmin on localhost for Windows
This gives you much more fine-grained access restrictions than Apache's URL permissions or an .htaccess file can provide, at the MySQL user name level.
Make sure that the user you are login in with, has its MySQL
Host:
field set to127.0.0.1
or::1
, as phpMyAdmin and MySQL are on the same system.One of my concerns with phpMyAdmin was that by default, all MySQL users can access the db. If DB's root password is compromised, someone can wreck havoc on the db. I wanted to find a way to avoid that by restricting which MySQL user can login to phpMyAdmin.
I have found using AllowDeny configuration in PhpMyAdmin to be very useful. http://wiki.phpmyadmin.net/pma/Config#AllowDeny_.28rules.29
AllowDeny lets you configure access to phpMyAdmin in a similar way to Apache. If you set the 'order' to explicit, it will only grant access to users defined in 'rules' section. In the rules, section you restrict MySql users who can access use the phpMyAdmin.
Now you have limited access to the user named pma-user in MySQL, you can grant limited privilege to that user.
You can use the following command :
Explanation:
Make sure your IP isn't listed before piping through iptables drop!!
This will first find all lines in $path_to_access.log that have phpmyadmin in them,
then grep out the ip address from the start of the line,
then sort and unique them,
then add a rule to drop them in iptables
Again, just edit in
echo %
at the end instead of the iptables command to make sure your IP isn't in there. Don't inadvertently ban your access to the server!Limitations
You may need to change the grep part of the command if you're on mac or any system that doesn't have grep -P. I'm not sure if all systems start with xargs, so that might need to be installed too. It's super useful anyway if you do a lot of bash.