NGINX is a very fast open source Webserver, its faster and more resource-friendly than Apache in most cases and can be used as a web server or a reverse proxy.

Nginx has gained a lot of popularity these days and is responsible for hosting some of the largest and highest-traffic sites on the internet.

Its quicker because it doesn’t need to spawn new processes or threads for each request like Apache does. Hence it also has a low memory foot print. It doesn’t support .htaccess files in its quest for speed and rewrite rules that you would write in .htaccess files for Apache are included in the virtual host configuration files. There could be others like the architecture etc

Nginx on Stackoverflow

Installation steps

sudo apt-get update
sudo apt-get install nginx
sudo ufw allow 'Nginx HTTP'
systemctl status nginx
Basic Installation commands on ubuntu (Allowing HTTP traffic)

If you don’t see any errors after each of these commands, this means Nginx is installed and running. Head over to your server IP to see the default loading page.

Path where default vhost file is located
sudo service nginx start
Command to run Nginx as a service


# Apache userdir simulation.
location ~ ^/~([^/]+)(/.*)?$ {
    alias /home/$1/public_html$2;
    autoindex on;
    ssi on;
Simulating Apache’s UserDir, with nginx
server {
    listen 80;


    location / {
        proxy_pass http://localhost:4567;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;

Reverse proxy Snippet
location ~ \.php {
    include /etc/nginx/fastcgi_params;
    keepalive_timeout 0;
    fastcgi_param SCRIPT_FILENAME /var/www/html/$fastcgi_script_name;
    fastcgi_index index.php;
FastCGI for PHP, Python or Ruby.