How to install Nginx on Ubuntu 22.04, 20.04, and Linux-based systems. This will help you easily create websites and manage your web server. Nginx is an open-source proxy server that utilizes popular protocols such as HTTP, HTTPS, SMTP, POP3, and IMAP. Nginx comes with essential core features for a web server, making it lightweight compared to Apache.
How to Install Nginx on Ubuntu 22.04 and 20.04 or Debian Linux
1. Update the system and install Nginx Server
Nginx is available in the Linux repositories so you can install it with APT. The first is to run the command below to update the packages in the system.
sudo apt update && sudo apt upgrade -y sudo apt install -y nginx -y
Of course, to keep the website/app up and running all the time, and if you use it on localhost, you don’t need to start it every time you open your computer, run the command to allow Nginx to start with the system.
sudo systemctl enable nginx
2. Overview of Nginx Directory on Ubuntu & Linux
When you install Nginx on Ubuntu 22.04 | 20.04 and Linux successfully, all Nginx directories are in the /etc/nginx
directory, let’s learn about each directory and its configuration with itsmeit.co.
- /etc/nginx/conf.d: Directory containing your own config files.
- /etc/nginx/nginx.conf: Main config file
- /etc/nginx/sites-available/default: Default Virtual Hosts config file
- /etc/nginx/sites-available: An area for config files VirtualHost allows you to configure each site individually.
3. Some commands used in the Nginx server
sudo service nginx stop #Nginx stop sudo service nginx start #Nginx start sudo service nginx status #Nginx check status sudo service nginx restart #Nginx re start sudo nginx -t #Show syntax Nginx errors
4. How to remove and remove Nginx on Ubuntu | Linux
After completing the installation of Nginx on Ubuntu, including versions 22.04 and 20.04 or Linux Debian. Should you ever wish to uninstall Nginx, simply execute the following command:
sudo service stop nginx sudo service remove nginx sudo service purge nginx sudo apt autoremove sudo rm -rf /etc/nginx
References:
– Advertising –