Today we will see how to upgrade PHP to the latest version. FYI, PHP 5.5.8 released on 9th January 2014. Here, we will perform the operations on CentOS 6 and Debian 7 with stable version of PHP 5.4.4. Version stable is the version that we find by default when we install PHP without changing the deposits anyway.
Attention, it is very important to take a full backup of the server or a snapshot if it is a virtual machine before performing process of upgrade. Note: it is possible to quickly see the version of PHP installed on your machine through the following command line.
When you use the standard version, you will see the following type of result on CentOS
Through this command you will clearly see which version is currently installed on the machine. However, make sure PHP CLI package is installed. If it’s not installed then you can install it via command line. For example:
sudo apt-get install php5-cli
It is necessary to have CLI package because PHP binary requires being included to your path. When you run php –v command and gets not output, then it’s certain that it’s not in your path.
You can also check the path with “echo $PATH”. If the directory where the PHP binary is installed is not in your path, then you can set it with export; for example: PATH=$PATH:/path/to/php.
First, uninstall the current PHP version so it will not conflict with newer version’s packages. Note: you must save your precautionary configuration files in a directory. We will see now how to create that directory.
cp -Rf /etc/php* /root/configphp
Then delete the version of PHP on your machine by using below command in CentOS:
yum remove php php-cli php-common && yum clean all
To uninstall PHP under Debian:
apt-get remove --purge php5
Now download and install the latest version deposit containers from PHP.
• Download and process deposits under CentOS
Yum that is able to download and install via its deposits option
• How to download Debian repositories
Under Debian, include two lines of deposits which are simple URL containing the deposits file (/etc/apt/source.list)
echo “deb http://packages.dotdeb.org wheezy-php55 all” >> /etc/apt/source.list
echo “deb-src http://packages.dotdeb.org wheezy-php55 all” >> /etc/apt/source.list
Now download and then install the signing key deposit which avoids errors during installation and updates:
apt-key add dotdeb.gpg
And now update the deposits in question: