Debian | Installation of Nginx 1.16

Nginx 1.14 is installed with default debian 10 repository.

Please refer to the steps below on how to install Nginx 1.16

Install curl & gnupg

sudo apt-get install curl gnupg -y

Add the official repository from nginx and the siging key

#Official Repository from Nginx 
echo "deb buster nginx" | sudo tee -a /etc/apt/sources.list.d/nginx.list
echo "deb-src buster nginx" | sudo tee -a /etc/apt/sources.list.d/nginx.list

#Add the signing key 
curl -L | sudo apt-key add -

Update Repository and install nginx

sudo apt-get update 
sudo apt-get install nginx -y

#verify nginx version installed
sudo nginx -v
    nginx version: nginx/1.16.1

Start Nginx services and enable it to start automatically

#Start and Enable Nginx on startup
sudo systemctl start nginx 
sudo systemctl enable nginx

Go to http://NGINX_IP to verify Nginx is up and running fine

Optional Steps

Change default root location (/usr/share/nginx/html/)

Make a backup of the default nginx configuration file – /etc/nginx/conf.d/default.conf

#Make a copy of the default nginx configuration file 
sudo cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak

Change the root under localtion / to /var/www/html

#Edit default nginx configuration file
sudo nano /etc/nginx/conf.d/default.conf

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /var/www/html;
        index  index.html index.htm;

Create /var/www/html and change the owner to www-data

sudo mkdir -p /var/www/html
#Change the owner of /var/www/html to www-data from root 
sudo chown -R www-data:www-data /var/www/html
#Add nginx and user who will edit the html files in /var/www/html to www-data group
sudo usermod -aG www-data nginx 
#Change the permission for /var/www/html to have write permission for users in www-data group 
sudo chmod 777 /var/www/html

Create a new index.html file

nano /var/www/html/index.html

<!DOCTYPE html>
<html lang="en">

    <meta charset="UTF-8">
    <title>Bulma Example</title>


<h1> NEW My Testing Web!!! </h1>


Go to http://NGINX_IP and the content in the new index.html should displayed

Scroll to Top