Table of Contents
This tip is about the how to Configure and Run Nginx on Ubuntu. So read this free guide, How to Configure and Run Nginx on Ubuntu step by step. If you have query related to same article you may contact us.
How to Configure and Run Nginx on Ubuntu – Guide
Nginx is one of the most used web servers on the planet. It has become the backbone of probably the best websites on the planet, including Netflix, WordPress.org, and that’s just the tip of the iceberg. Truth be told, we even use Nginx to administer our own site.
Nginx has proven itself as one of the fastest and lightest web servers. This exposure is due, to some extent, to the unusual way of handling requests. This contrasts with Apache’s more experienced approach, which used strings to handle the demands.
In addition to functioning as a web server, it can also be used as an opposite proxy, load balancer, mail broker or even an HTTP store. In any case, we may be dealing with using Nginx as a web server.
system requirements
For this tutorial, we will use the following:
These requirements change based on the expected traffic flow to your website. For an update, check out ServerMania’s range of offers. To host Ubuntu 20.04 on a ServerMania server, see Hosting Ubuntu on ServerMania.
Configure Ubuntu 20.04
root @ localhost: ~ # ssh root @ servermania_server_ip
root @ localhost: ~ # adduser smuser
root @ localhost: ~ # usermod -aG sudo smuser
ssh smuser @ servermania_server_ip
Install Nginx (Ubuntu 20.04)
sudo apt updatesudo apt-get update
sudo apt install nginxsudo apt-get install nginx
Configure Firewall for Nginx
sudo apt install ufw
sudo ufw status
sudo ufw allow ‘Nginx HTTP’
sudo ufw allow ‘OpenSSH’
sudo ufw enable
Nginx Installation and Management
sudo systemctl status nginx
http: // servermania_server_ip
sudo systemctl stop nginx sudo systemctl start nginx sudo systemctl restart nginx
systemctl reload nginx # reloads nginx configuration
Configure Server Blocks
sudo mkdir -p /var/www/domainone.com/htmlsudo mkdir -p /var/www/domaintwo.com/html
sudo chown -R $ user: $ user /var/www/domainone.com/html sudo chown -R $ user: $ user /var/www/domaintwo.com/html
sudo chmod -R 755 / var / www
nano /var/www/domainone.com/html/index.html
Welcome to ServerMania’s Domain One! You reached Nginx via server block #1
sudo cp / etc / nginx / sites-available / default /etc/nginx/sites-available/domainone.com
sudo ln -s /etc/nginx/sites-available/domainone.com / etc / nginx / sites-enabled /
Final note
I hope you like the guide How to Configure and Run Nginx on Ubuntu. In case if you have any query regards this article you may ask us. Also, please share your love by sharing this article with your friends.