Arun Yadav
Posted on April 3, 2021
Follow me on Twitter
What is nginx
Nginx, pronounced like “engine-ex”, is an open-source web server that, since its initial success as a web server, is now also used as a reverse proxy, HTTP cache, and load balancer.
How Does Nginx Work
Nginx is built to offer low memory usage and high concurrency. Rather than creating new processes for each web request, Nginx uses an asynchronous, event-driven approach where requests are handled in a single thread.
With Nginx, one master process can control multiple worker processes. The master maintains the worker processes, while the workers do the actual processing. Because Nginx is asynchronous, each request can be executed by the worker concurrently without blocking other requests.
Installing Node on Ubuntu
Executing the following bash commands will setup NodeJS and npm on your Ubuntu machine:
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install nodejs-legacy
sudo apt-get install npm
Installing NGINX on Ubuntu
sudo apt-get update
sudo apt-get install nginx
Serving Static Contents
Let’s start simple and first, we will use NGINX to serve a static website in our first demo.
Configuring NGINX
Configuration files can be found on /etc/nginx/. NGINX comes with a default site config file and we can open it using nano:
sudo nano /etc/nginx/sites-available/default
We will not change anything in this file yet but if we do, we have to restart the NGINX server afterward to make these changes take effect.
sudo service nginx restart
In this post, we saw how to serve static web applications using NGINX. Follow me on Twitter
Posted on April 3, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.