HomeAbout MeContact
Install Linux, Nginx, MySQL, PHP (LEMP stack) on Ubuntu 20.04

Step 1 – Installing the Nginx Web Server

sudo apt update
sudo apt install nginx

If you have the ufw firewall enabled, as recommended in our initial server setup guide, you will need to allow connections to Nginx.

sudo ufw app list

Since you haven’t configured SSL for your server in this guide, you will only need to allow regular HTTP traffic on port 80

sudo ufw allow 'Nginx HTTP'

Step 2 — Installing MySQL

sudo apt install mysql-server
sudo mysql_secure_installation

Step 3 – Installing PHP

sudo apt install php-fpm php-mysql

Step 4 — Configuring Nginx to Use the PHP Processor

sudo mkdir /var/www/your_domain
sudo chown -R $USER:$USER /var/www/your_domain
sudo nano /etc/nginx/sites-available/your_domain

This will create a new blank file. Paste in the following bare-bones configuration:

server {
    listen 80;
    server_name your_domain www.your_domain;
    root /var/www/your_domain;

    index index.html index.htm index.php;

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
     }

    location ~ /\.ht {
        deny all;
    }

}

Activate your configuration by linking to the config file from Nginx’s sites-enabled directory:

sudo ln -s /etc/nginx/sites-available/your_domain /etc/nginx/sites-enabled/your_domain
sudo unlink /etc/nginx/sites-enabled/default
sudo nginx -t
sudo systemctl reload nginx

Video tutorial


Anh Nguyen

Anh Nguyen

DIGITAL SOLUTIONS ARCHITECT

Table Of Contents

1

Step 1 – Installing the Nginx Web Server

2

Step 2 — Installing MySQL

3

Step 3 – Installing PHP

4

Step 4 — Configuring Nginx to Use the PHP Processor

5

Video tutorial

Related Posts

Manual install Saleor 3.0 on Window 10
Anh Nguyen
25/02/2021
1 min
© 2021, All Rights Reserved.

Quick Links

Advertise with usAbout UsContact Us

Social Media