Explain
Easy Guide: Install Nginx on Ubuntu 22.04 , follow our step-by-step tutorial to install Nginx on Ubuntu 22.04. Get started now!. Nginx is a web server that is still widely used by devops, as well as full stack developers. Its very lightweight advantages and ease of installation are what makes this nginx still very popular with some developers from beginner to middle up.
This time I’m going to give you a simple but baseless tutorial from the beginning of the setup to the end. The operating system I’m using is Ubuntu Server 22.04, if anyone uses another version it should be the same there is no difference, but if there are differences and difficulties please comment below so that we can discuss it. Learn how to install Nginx on Ubuntu 22.04 with this easy guide. Perfect for beginners!
Condition
Before you start, make sure you have a vps that already has an Ubuntu Server operating system, if you haven’t, I recommend buying it here Niagahoster. They have many cheap servers like VPS, Cloud and also Web Hosting.
When you have a server please login as a non-root user.
Step 1 – Install Nginx on Ubuntu 22.04
Actually Nginx or Apache is a default Web Server in Ubuntu Server, but you have to activate first from default repositories package of Ubuntu. You have to update it first and install it like this:
sudo apt update
sudo apt install nginx -y
Step 2 – Adjusting the Firewall
Approximately all ubuntu servers today no longer need to adjust the firewall, but there are still some things that need to be done. If your servers or vps have not done so please do the following:
sudo ufw app list
You will get this output:
Output
Available applications:
Nginx Full
Nginx HTTP
Nginx HTTPS
OpenSSH
We need to enabled the Nginx HTTP to firewall rule by doing this:
sudo ufw allow 'Nginx HTTP'
Check the firewall status and ouput:
sudo ufw status
Output
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
Nginx HTTP ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
Nginx HTTP (v6) ALLOW Anywhere (v6)
Step 3 – Check Nginx Status
If your installation is running smooth without an error, when you check the nginx status you will get the output:
sudo service nginx restart
Output
● 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 Fri 2022-03-01 16:08:19 UTC; 3 days ago
Docs: man:nginx(8)
Main PID: 2369 (nginx)
Tasks: 2 (limit: 1153)
Memory: 3.5M
CGroup: /system.slice/nginx.service
├─2369 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
└─2380 nginx: worker process
Nice!, your web server is absolutely running well, you can check your IP or domain to web browser , or you can check by curl in your command line server:
curl http://<yourdomain.com> #your domain
curl http://<ipaddress> #your IP address
Now you are successfully installed your web server on NGINX, before we move to another content, i’ll give you some cheat sheet to managing the nginx process:
sudo service nginx start # for start nginx
sudo service nginx stop # for stop nginx
sudo service nginx status # for status nginx
sudo service nginx restart # for restart nginx
sudo service nginx status # for status nginx
Finally finished for the nginx installation process, tutorials are not finished, after this you will do the settings for block servers in the Nginx so that your applications can appear well in the browser. Next Tutorial How to Setup Server Blocks NGINX.