- Nikhil Bhaskar
- June 24, 2021
How to Install & Configure Nginx web service on Ubuntu 20.04 LTS.
Web Server is a open-source software that means we can easily used and modified freely.We can easily install & configure web servers like Nginx.
The basic objective of the web server is to store, process and deliver web pages to the users. This intercommunication is done using Hypertext Transfer Protocol (HTTP).We can easily create an application in HTML or PHP & run on a web server.
Install Nginx Web Server
Update the required packages.
apt-get update
Install nginx web server.
apt-get install nginx
Start & Enable Nginx Service.
systemctl start nginx
systemctl enable nginx
Check Nginx Status.
systemctl status nginx
Here is the command output.
Access Nginx Web Interface
- Access Nginx Web Interface by using the URL.
http://server-ip
Here is the URL output.
Go to /var/www/html/ directory.Edit the index.nginx-debian.html page.We can create own .html page.
cd /var/www/html
vim index.html
Restart apache2 service
systemctl restart nginx
If we needs to create own directory & .html page or php.info page.
mkdir example
cd example
vim index.html
Edit
default Configure file.Set Document Root path & Restart the service.
vim /etc/nginx/sites-available/default
Create own Configure file.
vim /etc/nginx/sites-available/example
Provide the code.
server {
listen 80;
listen [::]:80;
server_name server-name.com;
root /path/of/example/folder;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
Enable the config file
ln -s /etc/nginx/sites-available/example /etc/nginx/sites-enabled/
Restart Nginx Service
systemctl restart nginx