Nginx/Setup/

How to install Nginx on an Ubuntu server?

Published on

How to install Nginx on an Ubuntu server?
If we want to host a website on a Linux server, we must need software to handle the request from the Clients and send a response back to them. For this purpose, we use a program called web server (Nginx) which handles the request from the browser and serves the requested web pages. 

Method 1: Install Nginx from Ubuntu Repository.

  • update the repository information:

1sudo apt-get update

 

  • install Nginx

1sudo apt-get install nginx -y

 

  • To autostart Nginx after restarting the Ubuntu server, execute the following commands.

So when you stop and start the Ubuntu server, systemctl will automatically start the Nginx service.

1sudo systemctl enable nginx

 

  • Check Nginx status by executing the below command, If the status is running you’re ready to go.

1systemctl status nginx



  • To stop the process of the Nginx server, execute the following commands.

1sudo systemctl stop nginx

 

  • To start the process of the Nginx server, execute the following commands.

1sudo systemctl start nginx

 

  • To restart the process of the Nginx server, execute the following commands.

1sudo systemctl restart nginx

 

Comments