Here is how to install Nginx on Ubuntu 20.04 in under two minutes:
Step 1 - Update the package list on your system
The first step is to update the package list on your system before proceeding to actual installation:
sudo apt update -y
apt update
downloads the package lists from the repositories and updates
them to get information on the newest versions of packages and their
dependencies. It will do this for all repositories and PPAs.
Step 2 - Install Nginx
Now, install nginx
package using the apt install command:
sudo apt install nginx
Step 3 - Adjust the firewall
We are not done quite yet. Now you need to adjust the firewall to allow web traffic.
sudo ufw allow 'Nginx HTTP'
Final steps
Now, everything is installed and ready to go.
To test if the service is running, execute the following command:
systemctl status nginx
To stop the service, execute this command:
sudo systemctl stop nginx
To start the service, execute this command
sudo systemctl start nginx
That’s it
You successfully installed Nginx on your system. You can go ahead and type your server's IP into the browser to see the default Nginx page (if the server is running).
Make your mark
Join the writer's program
Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.
Write for us
Build on top of Better Stack
Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.
community@betterstack.comor submit a pull request and help us build better products for everyone.
See the full list of amazing projects on github