PHP 5.5, 5.6, or 7.0—Ubuntu

Contents

If you must install both Apache and PHP, install Apache first.

PHP versions supported

Magento requires:

  • 7.0.6 up to 7.1.0

    PHP 7.1 is not supported

    There is a known PHP issue that affects our code compiler when using PHP 7.0.5. We recommend you not use PHP 7.0.5.

  • PHP 5.6.x
  • PHP 5.5.x, where x is 22 or greater

Magento no longer supports PHP 5.4.

Help if you're just starting out

If you’re new to all this and need some help getting started, we suggest the following:

Verify PHP is installed

To verify if PHP is installed already, enter php -v. If PHP is installed, messages similar to the following display:

PHP 5.6.4-1+deb.sury.org~precise+1 (cli) (built: Dec 21 2014 19:26:25)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies

The preceding message confirms that the Zend OPcache is installed. We strongly recommend using the OPcache for performance reasons. If your PHP distribution does not come with the OPcache, see the PHP OPcache documentation.

If PHP is installed, continue with the next prerequisite, MySQL.

If PHP is not installed, see one of the following sections:

PHP 7.0 on Ubuntu 14 or 16

To install PHP 7 on Ubuntu 14:
  1. Enter the following commands in the order shown:

    sudo apt-get -y update
    sudo add-apt-repository ppa:ondrej/php
    sudo apt-get -y update
    sudo apt-get install -y php7.0 libapache2-mod-php7.0 php7.0 php7.0-common php7.0-gd php7.0-mysql php7.0-mcrypt php7.0-curl php7.0-intl php7.0-xsl php7.0-mbstring php7.0-zip php7.0-bcmath php7.0-iconv
    

    The bcmath extension is required for Magento Enterprise Edition (EE) only.

  2. Enter the following command to verify PHP 7 installed properly:

    php -v
    

    Following is a sample response that indicates PHP 7.0.8 is installed:

    PHP 7.0.8-2+deb.sury.org~trusty+1 (cli) ( NTS )
    Copyright (c) 1997-2016 The PHP Group
    Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
      with Zend OPcache v7.0.8-2+deb.sury.org~trusty+1, Copyright (c) 1999-2016, by Zend Technologies
    

    The preceding message confirms that the Zend OPcache is installed. We strongly recommend using the OPcache for performance reasons. If your PHP distribution does not come with the OPcache, see the PHP OPcache documentation.

  3. Required PHP settings.

PHP 5.6 on Ubuntu 14

To install PHP 5.6 or to upgrade from PHP 5.5 on Ubuntu 14:
  1. Enter the following commands in the order shown:

    apt-get -y update
    add-apt-repository ppa:ondrej/php
    apt-get -y install php5.6 php5.6-mcrypt php5.6-mbstring php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-xsl php5.6-zip
    apt-get -y update
    
  2. Enter the following command to verify PHP 5.6 installed properly:

    php -v
    

    Following is a sample response that indicates PHP 5.6 is installed:

    PHP 5.6.22-4+deb.sury.org~trusty+1 (cli)
    Copyright (c) 1997-2016 The PHP Group
    Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
    

    The preceding message confirms that the Zend OPcache is installed. We strongly recommend using the OPcache for performance reasons. If your PHP distribution does not come with the OPcache, see the PHP OPcache documentation.

  3. Required PHP settings.

PHP 5.5 on Ubuntu 14

To install PHP 5.5 on Ubuntu 14:
  1. Enter the following commands in the order shown:

    apt-get -y update
    apt-get -y install php5 php5-mcrypt php5-curl php5-cli php5-mysql php5-gd php5-intl php5-xsl
    
  2. Verify the PHP version by entering php -v. Messages similar to the following should display:

    PHP 5.5.9-1ubuntu4.4 (cli) (built: Sep  4 2014 06:56:34)
    Copyright (c) 1997-2014 The PHP Group
    Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
    

    The preceding message confirms that the Zend OPcache is installed. We strongly recommend using the OPcache for performance reasons. If your PHP distribution does not come with the OPcache, see the PHP OPcache documentation.

  3. Required PHP settings.