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’s the Best Way to Start Learning Crypto Coding?

Hey everyone! I'm totally new to coding and I'm really eager to learn. I recently watched a video that mentioned picking a specific area...

Looking for Guidance to Transition from Front-End to Full-Stack Development

Hey everyone! I've been working as a front-end developer for over five years, primarily with React. Lately, I've been feeling a bit stuck, especially...

Help! My Old Employer Changed My Apple ID After I Quit

I made a mistake by using my personal Apple ID on my work Mac, and now I'm in a bit of a jam. When...

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

Raffle Ticket Generator

If you're running a fundraiser, charity draw, or local event and need raffle tickets fast, this free online tool lets you generate and print...

Random Number Generator – Create Multiple Random Numbers Instantly

Welcome to our free, browser-based Random Number Generator – a fast and flexible tool designed to help you generate as many random numbers as...

Instant Online Dice Roller

Need a quick, trustworthy way to roll dice without digging through a board‑game box or cluttering your desk? Our free online dice roller is...

Docx To PDF

Need to turn a Word document into a fully‑formatted PDF—without installing software or handing over your email address? Our free DOCX‑to‑PDF converter does exactly...

xAI Grok Token Calculator

This tool is a simple xAI Grok token calculator that helps you estimate the number of tokens your input text might consume when working...

DeepSeek Token Calculator

This tool is a straightforward DeepSeek token calculator, created to help you estimate how many tokens your text may use when working with DeepSeek...

Latest Posts

Latest Questions