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

What are the best ways to back up Azure Files offsite?

I'm stepping into a new setup where the previous managed service provider configured the organization to use Azure Files, but they only have snapshot...

How can I write a program that counts character combinations in text?

Hey everyone! I'm currently working on a math project where I need to write a code that counts character combinations in a given piece...

Help! Both My iPads Are Locked Due to Apple ID Issues

I'm really struggling with two iPads due to Apple ID problems. My son had an iPad Air that I couldn't update, download apps, or...

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

Erase Gemini Nano Banana Watermark

Below is a simple content eraser tool. It works very similar to the content aware fill tool that is used in Photoshop. You can...

Keep Your Screen Awake Tool

This simple online stay awake tool prevents your computer screen from going to sleep while you have this page open. It runs entirely in your...

Neural Network Simulation Tool

The Neural Network Visual Builder is an interactive, client-side tool designed to demystify deep learning. It allows users to drag-and-drop neural network layers to...

Ray Trace Simulator – Interactive Optical Ray Tracing Tool

This ray trace simulator lets you visualise how light rays move through an optical system in real time. You can trace beams as they...

Interactive CPU Architecture Simulator

This is an Interactive CPU Architecture Simulator that provides a hands-on, visual learning experience for understanding how a processor executes code. It models a...

AI Image Upscaler

Our AI Image Upscaler allows you to upload any image and instantly increase its resolution using advanced upscaling models. Choose between 2x, 3x or...

Latest Posts

Latest Questions