The easiest way to obtain PHPUnit is to download a PHP Archive (PHAR) that has all required (as well as some optional) dependencies of PHPUnit bundled in a single file.
Open the terminal and type:
wget https://phar.phpunit.de/phpunit.phar # download the PHP Archive (PHAR) file
chmod +x phpunit.phar
sudo mv phpunit.phar /usr/local/bin/phpunit
There are many different versions of phpunit.phar at https://phar.phpunit.de/. If you use the first command, it will select and download the latest version of phpunit.phar.
First you need to remove all php5 files :
sudo apt-get remove --purge `dpkg -l | grep php | grep -w 5.5 | awk '{print $2}' | xargs`
After that try to search for php 5.4. available resources :
apt-cache policy php5
My result :
php5:
Installed: (none)
Candidate: 5.5.9+dfsg-1ubuntu4.4
Version table:
5.5.9+dfsg-1ubuntu4.4 0
500 http://archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
500 http://archive.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages
5.5.9+dfsg-1ubuntu4 0
500 http://archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
If there is no resources available than we need to add some by following command :
echo "deb http://php53.dotdeb.org stable all" | sudo tee -a /etc/apt/sources.list
and
apt-get update
If there is a problem with signatures like following :
Reading package lists... Done
W: GPG error: http://php53.dotdeb.org stable Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY xxxxxCODExxxx
we need to sign our Deb repository by commands :
gpg --keyserver keys.gnupg.net --recv-key xxxxxCODExxxx
gpg -a --export xxxxxCODExxxx | sudo apt-key add - apt-get update
After that execute :
sudo apt-get update
apt-cache policy php5
you should see last result :
php5:
Installed: (none)
Candidate: 5.5.9+dfsg-1ubuntu4.4
Version table:
5.5.9+dfsg-1ubuntu4.4 0
500 http://archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
500 http://archive.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages
5.5.9+dfsg-1ubuntu4 0
500 http://archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
5.4.33-1~dotdeb.1 0
500 http://php53.dotdeb.org/ stable/all amd64 Packages
and finally install your version by hitting :
apt-get install php5=5.4.33-1~dotdeb.1
Enjoy ;)
Best Answer
You could go with Ubuntu 10.04 Lucid. Security support runs out for that in less than a year, but that should give you enough time to patch your PHP.
In my opinion using an Ubuntu-supported package is preferable to compiling from source, and 10.04 does happen to have the version you want as its official package.
Eventually you are going to have to patch your PHP code, however. It shouldn't be that difficult to bring it into compatibility with later PHP versions: all issues will be well documented online, and there will only be a small number of issues that would affect backward compatibility. Older versions of PHP won't be supported forever and eventually you'll end up with security problems if you stick with PHP versions that are not officially supported.