How to install and Configure Nginx on Ubuntu Debian/Linux 11

Posted by

Nginx is an open-source web server software widely used as a load balancer, reverse proxy, and HTTP Cache. Nginx is popular because of its scalability, high performance, and reliability. It handles several simultaneous connections with low memory and CPU usage, giving it the advantage of serving web applications and websites with high traffic.

The other advantage of Nginx is that it is flexible and highly customizable, it supports both dynamic and static content as well as proxy request to backend services or other web servers, more advanced feature is that we can use Nginx to terminate SSL/TLS connections and to cache content that is frequently requested.

Installing Nginx on ubuntu step

first, we are required to upgrade the ubuntu system packages by running the command below:

sudo apt update
sudo apt upgrade
ubuntu updating packages

once the update and upgrade are complete, the next step is now to proceed and install the Nginx package;

sudo apt install nginx
Nginx installation

Once the install command is successful, the next process is for us to start the Nginx service

sudo systemctl start nginx
starting Nginx Service

the Nginx start service command will go silent indicating it was successful, next to run the command that will enable the Nginx service to start when the system boots

sudo systemctl enable nginx
Nginx on Boot

Installation is now complete and the service is set to auto-start on system boot, our next task is to verify the Nginx installation to confirm it is running well by visiting the IP address or hostname, our example is on (, by default the port is 80 when we have firewall the below command is ruined to allow incoming traffic on port 80

sudo ufw allow 80/tcp
Nginx Running

Configuration of Nginx

Configuration of Nginx is done through a configuration file located in /etc/nginx/nginx.conf, below is the sample Nginx that belongs to the installation we did above


To learn more on how to configure the Nginx file we recommend you use the documentation found on the Nginx Website https://nginx.org/en/docs/. The other place to get to learn more is by joining forums and communities where you can ask questions and get advice, these communities include Stack Overflow and Reddit, Also you can also reach us via [email protected] for more guidance

set up a website on nginx ubuntu debian/Linux 11

to set up the website to run you are required to create a new directory in the website’s files, you can use the command below

sudo mkdir -p /var/www/advancelearnlinux.com/html

we need to assign the required permissions to the directories that we have created above, the command below assists us grant that;

sudo chown -R $USER:$USER /var/www/advancelearnlinux.com/html
sudo chmod -R 755 /var/www/advancelearnlinux.com

The next item for us now is to create a simple HTML website named index.html we will be hosting in the Nginx

sudo nano /var/www/advancelearnlinux.com/html/index.html

The above command will open an editor window where we will place our HTML code for the website

<title>Welcome to Your Website</title>
<h1>Success! Your website is now running on Nginx.</h1> 

To save the code added to the editor use CTRL+O to save and CTRL+X to exit the editor window

The next item we are required to implement is to create a new virtual host configuration file for our website

sudo nano /etc/nginx/sites-available/advancelearnlinux.com

The Editor will open and then paste the following configuration files save and close

server {
    listen 80;
    listen [::]:80;

    root /var/www/advancelearnlinux.com/html;
    index index.html;

    server_name advancelearnlinux.com www.advancelearnlinux.com;

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

What follows is to enable the virtual host configuration file by creating a symbolic link to the sites-enabled directory

sudo ln -s /etc/nginx/sites-available/advancelearnlinux.com /etc/nginx/sites-enabled/

next is to test the configurations

sudo nginx -t
nginx test ok

restart the Nginx

sudo systemctl restart nginx

Open the website using your server’s public IP address or domain name in a web browser and that’s all, you will have hosted your website in Nginx.

Examples of websites and Applications running on Nginx

Here is a list of a few companies that run their websites and applications that run on Nginx

Here is a list of a few companies that run their websites and applications that run on Nginx including Netflix, Airbnb, Dropbox, Github, WordPress, Docker, and many more

One response

Leave a Reply

Your email address will not be published. Required fields are marked *