Upgrade PHP to latest version on Raspberry Pi 2
If you have a Raspberry Pi 2 you will be have PHP 5.4 installed.
If you want to upgrade to PHP 5.6 or whatever is the latest version, you will have to download the source files, and compile the application.
This is not as difficult as it may sound.
In your Raspberry Pi SSH Terminal:
# Check the PHP version using the following command
php -v
# Get the PHP source
# First find the latest version number from the PHP download page: http://php.net/downloads.php
# Download the latest version either by downloading to your PC and then using ftp to save it back to the Raspberry Pi
# wget http://uk1.php.net/distributions/php-5.6.14.tar.bz2
# where 'uk1.php.net' is your to your nearest mirror. Find the mirror list here: http://php.net/mirrors.php.
# Once on the Raspberry Pi (the location does not really matter as you will delete the source files anyway) unpack using:
tar -xvjf php-5.6.14.tar.bz2
# Change directory to the source folder
cd php-5.6.14
# Find any updates
sudo apt-get update
# Get and install libxml2-dev which is a library that is used to manipulate xml files
sudo apt-get install libxml2-dev
# Do a configure
./configure
# If on the Raspberry Pi 2
make -j4
# Otherwise
make
# The process of compiling does take a long time on a Raspberry Pi - at least an hour for me.
# Install the application
sudo make install
# Reboot to make sure changes are effective
sudo shutdown - r now
# Check PHP version
php -v
# Delete the downloaded source files