How to Install Nginx on Ubuntu Linux
Installing Nginx on Ubuntu Linux turns your computer into a fast web server that handles high traffic easily on versions like Ubuntu 20.04 LTS and later. Nginx is free server software that hosts websites and web apps directly on your system.
You set up Nginx using the apt package manager through the command line terminal. A few quick commands download the software, start the service, and verify that your new server runs correctly.
Install Nginx by running `sudo apt update` followed by `sudo apt install nginx`. Check its status with `sudo systemctl status nginx`.
How to use Nginx HTTP server on Ubuntu Linux
You can install Nginx Ubuntu using the apt package manager in just two steps. First, open your terminal and run sudo apt update to grab the latest software list, then run sudo apt install nginx to put the web server on your computer. Nginx is ready to run as soon as the installation finishes.
Nginx is available in Ubuntu repositories, so we can easily install it using the apt package management tool.
To install Nginx, run the commands below:
sudo apt update sudo apt install nginx
The commands above will install the Nginx HTTP server.
To find out if Nginx is installed and running, use the status check command below.
sudo systemctl status nginx
The command will output similar lines below when Nginx is running.
nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2021-09-15 12:27:58 CDT; 9s ago
Docs: man:nginx(8)
Main PID: 2711 (nginx)
Tasks: 2 (limit: 4651)
Memory: 3.0M
CGroup: /system.slice/nginx.service
├─2711 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
└─2712 nginx: worker process
Sep 15 12:27:58 ubuntu2004 systemd[1]: Starting A high performance web server and a reverse pro>
Sep 15 12:27:58 ubuntu2004 systemd[1]: Started A high performance web server and a reverse prox>
How to allow Nginx through the Ubuntu firewall
You must configure UFW (a built-in tool that lets you manage network traffic rules) to allow web traffic before visitors can reach your server. Run sudo ufw allow 'Nginx Full' in your terminal to open the correct network ports and make your Nginx site accessible from other computers.
If you're using UFW to manage the Ubuntu firewall, run the below commands to allow traffic.
sudo ufw allow 'Nginx Full'
That will allow full traffic to Nginx.
With the firewall opened, simply browse the server hostname or IP address to see if the Nginx default page is up.
http://localhost
You should see Nginx default welcome page.

How to configure Nginx on Ubuntu Linux
You will find all Nginx configuration files inside the /etc/nginx folder on your Ubuntu system. This main directory holds every settings file you need to change how your web server behaves, where it looks for website files, and how it handles incoming visitors.
On Ubuntu Linux, these are Nginx directory structures and configuration files.
All Nginx configuration files are located in the /etc/nginx directory. This is considered the Nginx home directory.
Nginx's main configuration file is /etc/nginx/nginx.conf. Global configuration settings are done in the file, but this file is rarely ever touched.
Nginx virtual host files, which define each individual website, reside in the `/etc/nginx/sites-available` directory. Administrators activate these website configurations, and Nginx then uses the activated configurations which link to the `/etc/nginx/sites-enabled` directory.
These are the command below to activate websites to link them to the /etc/nginx/sites-enable directory. (replace example.com.conf with your VirtualHost file)
sudo ln -s /etc/nginx/sites-available/example.com.conf /etc/nginx/sites-enabled/
The command above will create a symlink of the website configuration files found in the sites-available directory to the sites-enabled directory.
To deactivate a virtual host, use the command below. (replace example.com.conf with your website VirtualHost file).
sudo rm /etc/nginx/sites-enabled/example.com.conf
Nginx uses snippets to enhance and add additional functionalities in the /etc/nginx/snippets/ directory.
Snippets only load with Nginx when included within a server block.
Nginx server blocks can use code snippets stored in the `/etc/nginx/snippets` directory. To include a snippet within a server block, use the `include` directive. For instance, `include /etc/nginx/snippets/my_snippet.conf;` inserts the content of `my_snippet.conf` into the server block.
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
include snippets/mycustomsnippets.conf;
........Nginx also has log files (access.log and error.log) in the /var/log/nginx/ directory. You can view access and error logs in these files on Ubuntu.
Ubuntu Linux may contain additional Nginx configuration files beyond those already mentioned. A detailed tutorial will provide further instructions on using these other Nginx configurations.
Conclusion:
This Nginx installation guide explains how to install and use Nginx on Ubuntu Linux. You can report errors or suggest additions to the Nginx installation steps using the comment form.
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] use and run CGI script on Nginx, you must first install and configure FastCGI. With Nginx installed, run the command below to install […]
[…] you already have a web server like Nginx or Apache installed and running a website, you can use this method to generate a free […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx on Ubuntu […]
[…] How to install Nginx […]
[…] How to install Nginx on Ubuntu Linux […]
[…] How to install Nginx on Ubuntu […]