Last Updated:

Install nginx + php7.2 + mysql on Linux Machine

Installing a bunch of nginxphp7.2, and mysql server on Linux Ubuntu 16.04 and Linux Ubuntu 18.04

First, you need to run Terminal (ctrl + alt + t) update Ubuntu and packages:

And start with installing NGINX.
To do this, in the terminal we write:

Proceed to the installation of php7.2-fpm

In Ubuntu 18.04 it is enough to run the installation command in the terminal:

In Ubuntu 16.04 you must first add a repository and only after that proceed to the installation:

First of all, download and install the package python-software-properties to add a new repository.

Add a repository:

And update the packages:

After the update proceed to the installation:

After php-fpm is installed, proceed to the installation of mysql server.
To install MySql, just run the command:


After everything is installed, you need to configure NGINX and PHP-FPM.
Configure nginx.
Open the configuration file for the local host:

Find the server configuration and change to:

Configure php-fpm.
Open the file with PHP-FPM settings:

Check for the presence of this line (If it is not, then add it):

After performing all the manipulations, reload php-fpm and nginx (it is better to restart the PC to reboot all services):

To check for operability, create a PHP file:

And write in it:

Save ctrl + o and exit the editing ctrl + x.Then

open the browser and follow the link:

You should see a page with information about the current version of PHP with the following content:
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install nginx
sudo apt-get install php7.2-fpm
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.2-fpm
sudo apt-get install mysql-server
sudo nano /etc/nginx/sites-available/default
server {
	listen 80 default_server;
	listen [::]:80 default_server;

	root /var/www/html;

	index index.php index.html;

	server_name _;

	location / {
		try_files $uri $uri/ =404;
	}

	location ~ \.php$ { 
		try_files $uri =404; 
		include /etc/nginx/fastcgi.conf;
		fastcgi_pass unix:/run/php/php7.2-fpm.sock; 
	}
}
sudo nano /etc/php/7.2/fpm/pool.d/www.conf
listen = /run/php/php7.2-fpm.sock
sudo service php7.2-fpm restart
sudo service nginx restart
sudo nano /var/www/html/index.php
<?php
phpinfo();
localhost/index.php

 
phpinfo