Follow me on Twitter
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.
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.
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
sudo apt-get update sudo apt-get install nginx
Let’s start simple and first, we will use NGINX to serve a static website in our first demo.
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