How To Install / Upgrade To PHP 5.6 On CentOS / RHEL

Upgrading to PHP 5.6 should be a quick and easy, but as most of us have experienced first hand, things don’t always go smoothly. If you are doing this on a live web server then I suggest you put all your sites into maintenance mode before doing anything here. If you don’t do this you could end up dumping raw php code onto the users screen which could be bad bad news if the wrong kind of person sees it. It can be risky doing this if you aren’t too sure what you are doing, but ya gotta do what ya gotta do!

PHP 5.6 is not supported officially, so you are going to need to use a 3rd party repo. There is no need to worry about this, it’s perfectly safe. Start by setting up the repo, by executing one of the following commands, depending on whatever version of CentOS or RHEAL you are using.

CentOS / RHEL 7.x:

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

CentOS / RHEL 6.x:

rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

You now have things setup to install PHP 5.6 (easy right!). Before you install you should remove older versions of PHP to avoid any conflicts. You may still get conflicting plugins, but they are easy to sort once you know you are correctly running the latest version. So lets remove the current version of PHP.
!!!WARNING!!! This install is quick, but make sure you you have apache either disabled or any websites in maintenance mode. Your database info and raw php code may be served to the users browser if php is not installed when the request is made. Stopping apache is the quickest way around this, but a maintenance site is best advised.

yum remove php*

The star will remove everything you have installed that is related to php. You will be reinstalling everything for php 5.6 after this so everything will be fine.

Now that any older PHP libraries and plugins are removed we can install the latest version of PHP. Before you do this make sure you aren’t running anything like cPanel that does not support this version of PHP. You shouldn’t have any issues if you keep your system up to date.

yum install php56w

If you want to install any additional PHP libraries you can do so using yum, but make sure you specify “php56w” and not “php” on its own. You should know already what libraries you use, if you don’t know you will eventually get errors that should be easy to fix. If there are issues that mbstring or any php library is not installed you can install it by typing “php56w-name-of-lib”. Here are some sample libraries that you might need.

yum install php56w-xml php56w-mbstring php56w-opcache

Missing dependencies after installing??
You will likely have some missing dependencies after the upgrade. There is no need to worry, you can reinstall them nice and easy. For example, after the upgrade you discover that scripts are failing when they try to process images. There is a good chance that it’s because the image GD library is missing. Running “yum install php56w-gd” will install the package and the errors will go away. The same applies to any other error messages you might be coming across for missing dependencies.

Related Articles

Related Questions

WordPress Table of Contents Plus Not Working

I have been using this plugin for a while and i really like it. It seems to have completely stopped working recently. I can...

Function Keys Reversing Between Fn Actions And Normal

My keyboard has the usual F1 to F12 keys along the top. I use these for shortcuts in various applications. These keys also have...

Whirlpool Oven F6E6: Appliance Manager 1 Board Communication

I have a brand new Whirlpool oven W11I OM1 4MS2 H or (859991549450). I bought it alongside the microwave combi oven. I have had...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Latest Tools

List Sorting Tool

Welcome to our innovative list ordering and management tool. This next-level platform enables you to sort a list of items in ascending or descending...

Sudoku Solver

Welcome to our free online Sudoku solving tool, an interactive platform for puzzle enthusiasts seeking a break from a Sudoku conundrum. This advanced platform...

Apply Image Filters To Image

Digital imagery in the modern world is all about reinforcing emotions and stories behind each photo we take. To amplify this storytelling, we are...

Add Watermark To Image

As the world is increasingly consumed by digital media, protecting your original images is paramount. We are thrilled to introduce you to our innovative...

CSV To Xml Converter

Welcome to our CSV to XML converter tool, a convenient and user-friendly solution for all your data conversion needs. This versatile tool on our...

RGB Image Splitter

Welcome to our innovative RGB Splitter - a unique image analyzer tool that offers an in-depth peek into the building blocks of your photos....

Latest Posts

Latest Questions