wesupport

25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

Need help?

Our experts have had an average response time of 11.43 minutes in March 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

How to update PHP version in Amazon Linux to PHP 5.6

by | Dec 10, 2016

Did you know that each PHP version is fully supported only for two years from its initial stable release? Unsupported versions are vulnerable to security exploits, which is why you need to timely update PHP versions.

In the case of AWS, PHP upgrade should be performed in all server instances that run PHP, for securing them. But the upgrade steps may vary with the OS flavour in that server.

See how our server support team helps you!

What is Amazon Linux?

Amazon Web Services (AWS) provides computing instances to customers. Popularly termed EC2, these instances can be created in various OS flavours such as RHEL, Ubuntu, etc.

One such OS distribution is the Amazon Linux, which is a Linux distribution based on Red Hat Enterprise Linux (RHEL) and CentOS. AWS team offers this Amazon Linux distribution for use in their EC2 instances.

This Amazon Linux distribution is maintained with timely updates and official support from AWS. It also comes with all the required tools for communicating with the API.

As a result, the latest version of PHP – PHP 5.6 package – is only supported in the ‘Amazon Linux’ flavour of EC2 instances, as of now.

Today, we’ll see how to upgrade the version of PHP to 5.6 in Amazon Linux EC2 instances.

1. Take backups

Any software update has its own risk. So, before upgrading PHP and Apache, we first take a backup of the configuration and the settings.

The Apache configuration file ‘httpd.conf’, PHP configuration settings in ‘php.ini’ file, and other custom settings are backed up. These backups are helpful in reverting the services to working condition, if the upgrade fails.

We also take note of the modules or extensions installed and compiled into the web server, in order to restore the websites back to their working state, in case something goes wrong.

[Spending too much time managing your AWS instances? Our expert engineers take care of your infrastructure and ensure its smooth functioning. ]

2. Remove old versions of PHP and Apache

The next step is to remove the instances of old versions of Apache and PHP in the server instance, as these can conflict with the new install. Before removing, it is always important to stop the web server as otherwise it can get corrupted.

sudo service httpd stop
sudo yum remove httpd* php*

3. Update the packages

New versions and patches for software are released often. These packages are usually available in the official repository of the OS, such as ‘yum’ repository for CentOS.

Inorder to benefit from the latest features and security updates of the software,  we keep these packages updated in the server, by getting them from their repository.

Updating packages from the repository helps us ensure that we get the latest secure versions and dependencies. This is done using the commands:

sudo yum clean all
sudo yum update -y

4. Install new version of PHP and Apache

PHP 5.6 works only with Apache 2.4. So we usually go ahead and upgrade both Apache and PHP, if they are running older versions.

But this is not a hectic task, as they are available as a single package and can usually be installed using the command:

sudo yum install php56

The following packages and dependencies will be installed in the server:

amazon linux php 5.6

Update PHP in EC2 to Amazon Linux PHP 5.6

 

In certain cases, the installation may give errors due to dependency issues. In such cases, we analyse the dependency issues and resolve them.

5. Start the web server

Usually the web server would restart after the install and the latest versions would show. If not, we restart the Apache web server for the new versions of PHP and Apache to come into effect.

 

amazon linux php 5.6 restart apache

Restart apache webserver

6. Check the websites

Once the installation is complete, we verify the versions of Apache and PHP and confirm that they are upgraded to the latest – Apache 2.4 and PHP 5.6.

 

amazon linux php 5.6 version check

Verify and confirm the Apache and PHP versions

 

We do not stop there, by just confirming the Apache and PHP versions from the backend. Most important point check we do is to load the major websites in the browser and confirm that they are working fine.

Some web sites require additional PHP extensions or Apache modules for their proper working. By verifying the PHP settings using phpinfo(), we confirm that all the required settings are present for the site.

If any module or setting is missing, we install and enable them into the latest updated version and then try reloading the site to verify.

[ Managing your AWS infrastructure doesn’t have to be hard, or costly. Get world class AWS administration services at affordable pricing. ]

In short..

Updating PHP to version 5.6 is an easy process. But there are chances that it can end up breaking some working sites. That’s why proper backups and post-install checks are very important.

Here we discussed how to update Amazon Linux PHP to 5.6 in AWS EC2 instances. Though PHP 5.6 package is not supported in other OS versions as of now, it is still possible to update PHP to version 5.6 in them by compiling PHP from source.

If you’d like to get more assistance regarding PHP upgrade in your servers or want to make your server infrastructure more efficient, we’d be happy to talk to you.

 

Get your AWS instances updated!

Worried about upgrades and service errors in your servers? Let us help you.

GET IN TOUCH WITH AN EXPERT NOW!

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

3 Comments

  1. dusan

    thanks dude, very quick and efficient steps..

    Reply
  2. olidev

    That was unexpectedly simple. I didn’t know it was that quick to update PHP version on AWS. I was using Cloudways platform to host my PHP app on AWS (https://www.cloudways.com/blog/host-php-on-aws-cloud/ ). So, when it came time to update the version, I only had to select PHP 7 from the dropdown menu and made sure the code was up to date.

    Reply
  3. Daisuke

    Syntax error on line 3 of /etc/httpd/conf.d/mod_evasive.conf:
    Invalid command ‘DOSHashTableSize’, perhaps misspelled or defined by a module not included in the server configuration
    [FAILED]

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Categories

Tags