Install Nginx
The first step in creating a LEMP stack on Ubuntu 20.04 is by updating the package lists and installing Nginx.
sudo apt update && sudo apt install nginx
Type Y
and ENTER
if prompted.
Once installed, check to see if the Nginx service is running.
sudo service nginx status
If Nginx is running correctly, you should see a green Active state below.
â—Ź nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor pres>
Active: active (running) since Tue 2021-08-10 06:40:13 UTC; 8s ago
Docs: man:nginx(8)
Main PID: 2394 (nginx)
Tasks: 2 (limit: 1072)
Memory: 5.1M
CGroup: /system.slice/nginx.service
├─2394 nginx: master process /usr/sbin/nginx -g daemon on; mast>
└─2395 nginx: worker process
You may to type CTRL
+C
and hit ENTER
or Q
to exit the service status.
Configure Firewall
sudo ufw allow OpenSSH
Now you can access through Command Prompt using your root details.
Add new rules.
sudo ufw allow 'Nginx Full'
For both the output look like this:
Rules updated
Rules updated (v6)
Enable ufw
firewall.
sudo ufw enable
Press Y
when asked to proceed.
Now check the firewall status.
sudo ufw status
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
Nginx Full ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
Nginx Full (v6) ALLOW Anywhere (v6)
The Nginx component of your LEMP Stack on Ubuntu 20.04 should now be ready to serve web pages.
Test Nginx
Go to your web browser and visit your domain or IP. If you don’t have a domain name yet access by your IP.

You can find this Nginx default welcome page in the document root directory /var/www/html
. To edit this file in nano
text editor:
sudo nano /var/www/html/index.nginx-debian.html
To save and close nano, press CTRL
+ X
and then press Y
and ENTER
to save changes.
Your Nginx web server is ready to go. You can now add your own html files and images at /var/www/html
directory.
You've completed this section, now you can see your website at browser.
Last updated
Was this helpful?