Upgrading to PHP 7

Tim Bond

June 14 2016

About Me

  • Working with PHP for 12+ years
  • I do full stack LAMP dev
  • I work for Lightspeed GMI, a market research company in Bellevue

Why Upgrade?

  • Faster!
  • New features!
  • <5.5 is unsupported

Step one: Back up

Check for BC Breaks

Run the PHP 7

compatibility checker

Upgrading - Ubuntu

  • cat /etc/*release*
    • 15.04? sudo do-release-upgrade
  • dpkg --get-selections '*php*'
  • sudo add-apt-repository ppa:ondrej/php
  • sudo apt update

Upgrading - Ubuntu

  • sudo apt purge php5-common php5-dev
  • sudo apt-get autoremove
  • sudo apt install php7.0-mysqli php7.0-mysqlnd

Upgrading - Ubuntu

  • Configs moved:
    • /etc/php5/ vs /etc/php/7.0/
    • Good idea to keep your customizations separate:
      /etc/php/7.0/apache2/conf.d/99-yourapp.ini

Upgrading - Ubuntu

  • Apache:

    • sudo apt install libapache2-mod-php7.0
    • sudo a2enmod php7.0

Upgrading - CentOS

  • Webtatic repos contain PHP versions 5.4 and above
  • Need epel first
    • sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    • sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

Upgrading - CentOS

  • sudo yum remove php56w-common php56-dev
  • sudo yum install php70w-opcache

Upgrading - CentOS

  • Apache:

    • sudo yum remove mod_php56w
    • sudo yum install mod_php70w

Upgrading - CentOS

  • Config stays in the same location:

    • /etc/php.ini
    • /etc/php.d/

Xdebug

Questions?