Install LEMP on Ubuntu 18.04 with PHP 7.2 for Magento 2.3

12th January 2019 posted in Magento, NGINX, PHP, Ubuntu

In this tutorial we will install NGINX, Percona MySQL and all the PHP 7.2 extensions for Magento 2.3 on Ubuntu 18.04

First update your server

sudo apt update
sudo apt upgrade
sudo apt-get install -y openssh-server
sudo systemctl enable ssh
sudo systemctl status ssh
sudo systemctl start ssh
sudo ufw allow ssh
sudo ufw enable
sudo ufw status
sudo apt-get update &&
sudo apt-get upgrade

Install NGINX

sudo apt install nginx
To confirm NGINX is running
sudo service nginx status
You should see “active (running)” in green text.
Next visit the IP address of your server to verify NGINX has been installed, you should see this screen.

Install PHP 7.2

Next connect to your Linux VPS via SSH and enable the Ondrej’s PPA:

sudo apt-get -y update
sudo add-apt-repository ppa:ondrej/php
sudo apt-get -y update

Now you can install all PHP 7.2 and the required extensions for Magento 2.3

sudo apt-get install -y php7.2 libapache2-mod-php7.2 php7.2-common php7.2-gd php7.2-mysql php7.2-curl php7.2-intl php7.2-xsl php7.2-mbstring php7.2-zip php7.2-bcmath php7.2-iconv php7.2-soap php7.2-fpm

Now you need to edit the php.ini file, this is how you locate the file.

php --ini |grep Loaded
Loaded Configuration File: /etc/php/7.2/cli/php.ini

sudo nano /etc/php/7.2/cli/php.ini

Make the following change.

cgi.fix_pathinfo=0

Then, restart the PHP-FPM service

sudo systemctl restart php7.2-fpm.service

Verify if PHP is installed, run the following command
php -v
PHP 7.2.14-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Jan 13 2019 10:05:45) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.14-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

You can view a PHP configuration page by creating a test page in the www root
sudo nano /var/www/html/info.php
Enter the following text, press CTRL+X and Y Enter to save the file.

Then visit the page http://IP_ADDRESS/info.php
You should see a configuration page like this.

Be sure to delete this page afterwards as it exposes server information and could be a security risk.

Finally install MySQL Percona

cd /home
sudo mkdir percona
cd percona
sudo wget https://repo.percona.com/apt/percona-release_latest.bionic_all.deb
sudo dpkg -i percona-release_latest.bionic_all.deb
sudo apt-get update
sudo apt-get install percona-server-server-5.7

To Delete mysql and start again

sudo apt purge mysql-server mysql-client mysql-common
sudo apt autoremove
sudo rm -rf /var/lib/mysql*

Tags: Magento 2, NGINX, PHP, Ubuntu