(Last Updated On: September 18, 2018)

Nginx is one of the fastest and most powerful web-servers available, powering over 45 million websites around the world.

To install Nginx on Ubuntu use the following command

apt-get install nginx

Nginx will be installed within /etc/nginx/ directory and you website files will be loaded from /var/www/html by default.

In order to install PHP7, use the following command

apt-get update
apt-get install php

 

It’s usually a good idea to install several popular PHP7 modules in order for your websites to function correctly:

apt-get install php-pear php7.0-dev php7.0-zip php7.0-curl php7.0-gd php7.0-mysql php7.0-mcrypt php7.0-xml libapache2-mod-php7.0 php-mysql

 

With that all installed, we now need to install PHP-FPM using the following command

sudo apt-get install php-fpm

By default, PHP-FPM will be installed in /etc/php/7.0/fpm/

in order to restart Nginx and PHP-FPM use the following commands

service nginx restart
service php7.0-fpm restart