Automatically update phpMyAdmin

I’m running phpMyAdmin to manage the MySQL databases for the hosting I manage, and I need to keep it up to date to avoid vulnerabilities, bugs, etc.

Or mainly because I want to see up to date in the version box.

I run this script weekly to keep my version up to date:

#!/usr/bin/php
<?php

$cmd = "cd /home/stephan/www/secret_folder/hidden; git clone --depth=1 --branch=STABLE git://github.com/phpmyadmin/phpmyadmin.git && cp -r phpmyadmin/* MyPHPMyAdmin/ && rm -rf phpmyadmin";
shell_exec($cmd);

I keep phpMyAdmin in an hidden folder, protected by a password, because a lot of scripts try to access it.

So, if the URL of your phpMyAdmin instance is

https://mywebsite.ch/secret_folder/hidden/MyPHPMyAdmin,

and is stored in

/home/stephan/www/secret_folder/hidden/MyPHPMyAdmin

the script above will fetch the latest stable release, and copy it OVER your existing version, to keep all your settings intact.

Run it via cron and you’re done. This script has been running for more than 1 year without any problem.