How to Setup the Nginx Web Server on Ubuntu 18.04

by | Feb 23, 2023 | Uncategorized

Igor Sysoev created the Nginx [engine x] HTTP and reverse proxy server, mail proxy server, and general-purpose TCP/UDP proxy server. It has been active for a very long time on numerous heavily trafficked Russian websites, including Yandex, Mail.Ru, VK, and Rambler. As of December 2022, 21.25% of the busiest websites were hosted by or proxied by Nginx, according to Netcraft. Additionally, it can fulfil requests for static resources faster than Apache, enabling you to carefully balance requests, boost speed, and make better use of available resources. You can learn how to set up the Nginx web server on an Ubuntu 18.04 system by reading this tutorial.

  • Root Access
  • Terminal Access
  • Server Running Ubuntu 18:04

Stages To SetUp Nginx Web Server on Ubuntu 18.04

  • SSH into the server and use the provided command to update the preset repository.

# sudo apt update


  • Run the provided command to install Nginx from the apt repository after the upgrade is complete.

# sudo apt install nginx


  • Run the provided command to verify the Nginx process’s status after the installation is finished.

# sudo systemctl status nginx


If the Nginx process isn’t already operating, try starting it with the provided command. The output will produce information about the Nginx process.


# sudo systemctl start nginx

# service nginx start


If the Nginx process is not already running, this will initiate it.


# sudo systemctl stop nginx: Stops the Nginx service
# sudo systemctl enable nginx: Enables Nginx to load at startup
# sudo systemctl disable nginx: Prevents Nginx from loading at startup


Firewall Configuration for Nginx Data

You should modify the firewall programme to permit access to the Nginx service before trying Nginx. During installation, Nginx registers with ufw as a service, making it simple to give access to Nginx. Enter the provided command to create a list of the apps that the firewall allows.


# sudo ufw app list


Full: This profile opens both port 80 (normal, unencrypted web traffic) and port 443 (TLS/SSL encrypted traffic)
HTTP: This profile opens only port 80 (normal, unencrypted web traffic)
HTTPS: This profile opens only port 443 (TLS/SSL encrypted traffic)

The inventory of applications that have access to the firewall rules will be generated by this command. There are three Nginx profiles in the roster. For the purposes of this lesson, port 80 will only be open to the Nginx HTTP profile. To enable Nginx HTTP traffic from the firewall, type the provided command.


You can now assess the firewall’s condition. It ought to show a list of the traffic that is permitted for various applications.


# sudo ufw status


Nginx Web Browser Evaluation

Open a web browser, like Chrome, and type in the address box the IP address of your server. It will display the Nginx welcome page.

Conclusion

After setting up a web server, you have a wide range of choices for the content types you serve and the technologies you employ to produce more immersive experiences. This tutorial showed us how to set up the Nginx Web Server on Ubuntu 18.04. Please get in touch with us if you have any ideas or queries.

Read Our Next Articles Rust Installation Guide for Ubuntu 18.04