Anonymous functions1 (closures) in PHP 5.3 are cool. Awesome is when you can use2 any variable with it. With PHP 5.4 you can even use $this.

The problem with use is that it is making the value available in the current scope by copying2 it, thus not modifying it upwards the chain. To over come this, simply pass by reference1.

1
$anon = function(){
// Some fancy execution right here
};
$anon();

2
$otherRandomVar = 5;
$anon = function() use ($otherRandomVar) {
// $otherRandomVar will be made available in $anon() by copy
// In this case it is not modifying its value in the global scope
$otherRandomVar = 8915 + 945;
};
echo $otherRandomVar; // 5

If you’d like the same personalized settings, simply copy the config files and folders from your /home/user located on the old machine -> onto the new machine. Same rule applies for other programs (apache, fpm, postfix): copy all files from /etc/apache, /etc/postfix and so on onto the new machine. For the future, using rsync or something similar might come more in handy.

This was the ‘hard way’ of cloning a server. Since the best sysadmin is a lazy sysadmin, you might want to consider Chef/Puppet/Ansible/SaltStack or any virtualization & cloning tool.