Looking for good programming challenges?

Use the search below to find our solutions for selected questions!

Upgrading to PHP 7 on Amazon Linux EC2 Instance

Sharing is caring!

By now you may know that PHP 7 has been available for quite some time now coming with a number of improvements over version 5. It may be wise to upgrade to PHP7 when running for instance a WordPress using Amazon AWS where you are responsible for any upgrades.

Also as of July 2016, Amazon officially added PHP7 to its repository so you can install it using yum. So first thing I did was create a backup image of my EC2 instance before I went on with the upgrade. Once I had my backups done and proceeded with the PHP 7 upgrade.

Here are the steps I took in order to upgrade from PHP 5.x to 7.

Login to your Linux instance and perform the regular system updates first

Stop the running web server

Remove any existing PHP packages

Remove old web server installs

Update yum package repository

Install Apache 2.4

Install PHP 7 packages

Install a new version of mod_ssl

I also needed to reconfigure /etc/httpd/conf/httpd.conf and /etc/httpd/conf.d/ssl.conf as I did in this post in order to enable SSL and pretty permalinks.

Finally all I needed to do is start my web server