Upgrading to PHP 5.5

October 30, 2014 / Dedicated Server Hosting

Today we will see how to upgrade PHP to the latest version. FYI, PHP 5.5.8 was released on 9th January 2014. Here, we will perform the operations on CentOS 6 and Debian 7 with the 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 the process of upgrade. Note: it is possible to quickly see the version of PHP installed on your machine through the following command line.

php –v

When you use the standard version, you will see the following type of result on the CentOS

php-suhosin-version

Through this command, you will clearly see which version is currently installed on the machine. However, make sure the PHP CLI package is installed. If it’s not installed then you can install it via the command line. For example:

sudo apt-get install php5-cli

It is necessary to have a CLI package because the PHP binary requires being included in your path. When you run php –v command and get 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.

Uninstalling PHP

First, uninstall the current PHP version so it will not conflict with the newer version’s packages. Note: you must save your precautionary configuration files in a directory. We will see now how to create that directory.

mkdir /root/configphp
cp -Rf /etc/php* /root/configphp

Then delete the version of PHP on your machine by using the below command in CentOS:

yum remove php php-cli php-common && yum clean all

To uninstall PHP under Debian:

apt-get remove --purge php5

Download deposits

Now download and install the latest version of 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 URLs 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:

wget http://www.dotdeb.org/dotdeb.gpg
apt-key add dotdeb.gpg

And now update the deposits in question:

apt-get update

Installing PHP 5.5.x

To install the PHP 5.5.8 packages, here is the command line in CentOS; we have moved here many extensions and modules that are not necessarily helpful, you can remove them from the command line if you don’t need them as well:

yum install –y php55u php55u-soap php55u-process php55u-pear \
php55u-mysql php55u-mcrypt php55u-mbstring php55u-gd php55u-devel php55u-json

It will show you all the packages that will be installed and their version (5.5.8 in this case under CentOS):

And the command line in Debian, we moved many extensions and modules that are not necessarily helpful; you can remove them from the command line if you don’t need them:

apt-get install php5 php5-mysql php5-common php5-mcrypt php5-dev php5-gd

You can then ensure that the version of PHP is very good with the following command:

php –v

You must then restore the configuration (/etc/php.ini) because it was removed when uninstalling PHP. It is best not back up the old configuration but rather to rewrite the new configuration values that changed.

Finally, restart the web service Apache2 which is the service most used coupling with PHP for CentOS:

service httpd restart

For Debian:

service apache2 restart

Note: Do a test on all types of web hosting services (CMS such as WordPress, Web Applications, Hand coded websites, etc…) to make sure there is no shortage of PHP modules or particular extensions. And conversely, do not install unnecessary extensions as above indicated. So check the extensions used on your system before updating.

And don’t forget to check your logs when using web services after the update to see if any extensions are missing or if problems arise.

Remember, take a full backup before upgrading PHP versions.

Incoming searches related to upgrading to php 5.5

  1. upgrade php 5.3 to 5.5 centos
  2. centos 6 upgrade php
  3. install php 5.5 centos
  4. debian upgrade php version
  5. upgrade php debian lenny
  6. linux upgrade php
  7. centos upgrade php