Ubuntu: Installing PHP 7.3 with Magento 2 extensions

Ubuntu Logo

In this post we look at installing various versions of PHP and the extensions required for a Magento 2 installation.




First we will add the ondrej/php repository to the OS and then install PHP.
*Change the php7.3 command to your desired version.

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.3
php -v

If the installation was successful you should see the below output after running the php -v command.

PHP 7.3.18-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: May 14 2020 10:34:44) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.18, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.18-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

Below is the command to install the required PHP extensions for Magento 2.
Both 7.3 and 7.4 are displayed for convenience.

sudo apt install php7.3-cli php7.3-fpm php7.3-json php7.3-pdo php7.3-mysql php7.3-zip php7.3-gd  php7.3-mbstring php7.3-curl php7.3-xml php7.3-bcmath php7.3-json php7.3-soap php7.3-intl

sudo apt install php7.4-cli php7.4-fpm php7.4-json php7.4-pdo php7.4-mysql php7.4-zip php7.4-gd  php7.4-mbstring php7.4-curl php7.4-xml php7.4-bcmath php7.4-json php7.4-soap php7.4-intl

Depending on your PHP version and environment you may require the following libsodium extension, This has been encountered on some custom Linux installs and it has been reported not working using XAMPP on Windows.

sudo apt install php-libsodium  

php.ini settings

memory_limit=2048Mb
realpath_cache_size=10M
realpath_cache_ttl=7200
opcache.memory_consumption=512Mb
opcache.max_accelerated_files=60000
opcache.consistency_checks=0
opcache.validate_timestamps=0
opcache.enable_cli=1 

Leave a Reply

Your email address will not be published. Required fields are marked *