PHP 5.5, 5.6, or 7.0—Ubuntu
If you must install both Apache and PHP, install Apache first.
PHP versions supported
Magento requires:
7.0.0, 7.0.1 | 7.0.2 | 7.0.3–7.0.5 | 7.0.6–7.0.x | 7.1.x |
5.6.x |
5.5.0–5.5.21 | 5.5.22–5.5.x |
5.4.x |
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:
- Is the Magento software installed already?
- What is the software that the Magento server needs to run?
- What operating system is my server running?
- How do I log in to my Magento server using a terminal, command prompt, or SSH?
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
-
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 php7.0-soap
The
bcmath
extension is required for Magento Commerce only. -
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. -
Continue with Required PHP settings.
PHP 5.6 on Ubuntu 14
-
Enter the following commands in the order shown:
apt-get -y update add-apt-repository ppa:ondrej/php apt-get -y update 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 php5.6-soap
-
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. -
Continue with Required PHP settings.
PHP 5.5 on Ubuntu 14
-
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 php5-soap
-
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. -
Continue with Required PHP settings.