So PHP 7 has been available since late last year.  This is the first major release since PHP 5 came out in 2004.  Yes, it took eleven years.  It’s not like it was abandoned, its just that things took a very winding path.  Notice that we went from version 5 to version 7.  There was going to be a version 6 and a lot of time went into its creation.  Unfortunately, parts of version 6 were overly ambitious.  While code was being written, life advanced on the internet and parts of version 6 became less and less necessary.  So they sorta skipped it, and here we are.

PHP 7 offers a number of improvements over version 5.  There are some significant performance improvements.  Depending on what you’re doing, PHP 7 can be up to twice as fast doing it.  The team also significantly reduced memory usage.  All very good things.  These changes along with many other improvements are exactly why you should be running it in production now.  Or at least in development with plans to move it into production.

It’s been possible to run PHP 7 on Amazon Linux since it’s release.  However, it required either compiling it yourself, or using additional repositories.  In July 2016, Amazon added PHP 7 into their official repository.  So now it can simply be installed via yum, which makes it super easy and therefore a quick blog post.

  • Step 1 is always the same: BACKUP
  • I assume you’re running this on a web server, so go ahead and stop Apache
    • sudo service httpd stop
  • Remove all of the PHP 5 packages
    • Take note of the packages that are being removed, as you’ll want to add in the same PHP 7 package (the names should be the same, or very close).
    • sudo yum remove php5*
  • Install all the new PHP 7 packages
    • For a list of all packages, use sudo yum list php7*
    • For example:
      • sudo yum install php70 php70-mysqlnd php70-imap php70-pecl-memcache php70-pecl-apcu php70-gd
  • Start Apache back up
    • sudo service httpd start
  • Test, test, test, test

That’s it.  The installation is pretty quick and painless.  I have yet to notice any issues on my installations, but definitely have noticed a speed boost.  Got a question?  Ask away!