Sunteți pe pagina 1din 3

Upgrading to PHP 5.

5
Today we will see how to upgrade PHP to the latest version. FYI, PHP 5.5.8 released on 9 th 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.
| php v
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 its 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 its certain that its 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 newer versions 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 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 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:
| 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 dont 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 dont need:

| 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 backup 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 website, 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 dont forget to check your logs when using web services after the update to see if any extensions
are missing or if problem arise.
PS: take a full back up before upgrading PHP versions.

S-ar putea să vă placă și