This is second article related to CentOS somewhat outdated default setup.
I have previously discussed Steps to update MySQL to 5.5 and now its time to look at PHP
If you run VPS or dedicated server with CentOS 6.x installed often you will find that default setup would include somewhat antiquated PHP and MySQL versions – 5.3 and 5.1 respectively.
Unfortunate situation dictated by the fact that main distro package used in such environment does not include latest versions.
If SSH and Linux management is allowed, it does not take long to bring environment up to date.
Note: it is much easier to update packages right away once server is still fresh and there is not much other software installed.
Update PHP to 5.5 on CentOS from SSH
Make sure you have root access to underlying Linux and open SSH session.
- Check version of PHP installed. Let’s assume PHP 5.3 or 5.4 is present. You should see something similar to the following output
# php -v
PHP 5.4.17 (cli) (built: Jul 23 2013 00:02:04)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
- Default CentOS repo accessible with yum would not have proper PHP version and you would need to add Webtastic repo with
# rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
- As mentioned above we are interested in latest stable version of PHP 5.5. Let’s make sure it is in fact available for installation
# yum list available | grep php55
then examine output to make sure php55w packages are present.
- Depend on your current configuration, you may need some additional PHP libraries (full list can be found here), so please take a note of what packages you have installed and setup in your system before proceeding with next step
- Now you can install the new PHP 5.5 core and packages. Options below is most basic and commonly used configuration for 64bit system
# yum install php55w.x86_64 php55w-cli.x86_64 php55w-common.x86_64 php55w-gd.x86_64 php55w-ldap.x86_64 php55w-mbstring.x86_64 php55w-mcrypt.x86_64 php55w-mysql.x86_64 php55w-pdo.x86_64
Once operation is completed, run PHP version check again, you should see that PHP version is now 5.5
# php -v
PHP Upgrade fails with dependency error “Error: php55w-common conflicts with php-common-5.3.3-23.el6_4.i686”
Since there is previous version of PHP present and we did not do clean uninstall, dependency resolution procedure may become “confused” and could not figure out what to do with common package.
Try the following two commands before you attempt installing PHP again
# yum install yum-plugin-replace
# yum replace php-common --replace-with=php55w-common
First will ensure that we do have replace option support and then update php-common package before we update PHP core
php -v command shows ionCube compatibility error
Simply put, ionCube extension is older version and not compatible with new PHP version.
What is the ionCube in the first place and why we better keep it?
ionCube is an PHP code encryption extension usually used with Zend Engine and allows protect otherwise open text PHP code from direct access and analysis. Many commercial PHP products would come encrypted and without this extension you may no longer will able to use them.
Let’s assume ionCube is here to stay and let’s see what we can do to reanimate it.
In some cases PHP would unable to load proper version of ionCube
Try the following:
- visit /etc/php.d folder and look for 00-ioncube-loader.ini or similar
- if located open for edit and check what zend_extension file is referenced to make sure proper version of the loader is used
php -v command shows timezone warning
PHP Warning: date(): It is not safe to rely on the system's timezone settings
This message easily to notice when you run php -v after upgrading to latest version of PHP as it is no longer set by default.
While not strictly necessary, I would recommend reboot your server. This may help with some phantom issues encountered rarely due to some ongoing active processes.
Don’t forget to log off and close your SSH session