In this guide, we will describe the commands for managing the Nginx Web server on an Ubuntu and a CentOS Server.

Deploying your cloud server
If you have not already registered with Cloudwafer, you should begin by getting signed up. Take a moment to create an account after which you can easily deploy your own cloud servers.

Once you have signed up, log into your Cloudwafer Client Area with the password provided in your mail and deploy your Cloudwafer cloud server.

Updating System Packages on Ubuntu
It is always recommended that you update the system to the latest packages before beginning any major installations. This is done with the command below:

sudo apt update
sudo apt upgrade

Updating System Packages on CentOS
It is always recommended that you update the system to the latest packages before beginning any major installations. This is done with the command below:

sudo yum update

Installing Nginx
Install Nginx using your server's package manager, apt for Ubuntu and yum for CentOS as shown below:

sudo apt install nginx            [On Ubuntu]

sudo yum install nginx            [On CentOS]

Checking Nginx Version
After installation, you can check the installed version of the Nginx web server on your Linux system, by issuing the following command:

sudo nginx -v                     [On Ubuntu]

sudo nginx -v                     [On CentOS]

Checking Nginx Configuration Syntax Errors
Nginx provides a command to check syntax errors in your Nginx configuration files in order to avoid errors when you restart the Nginx web server. This is shown below:

sudo nginx -t                    [On Ubuntu]

sudo nginx -t                    [On CentOS]

Starting Nginx Service
To start the Nginx service, issue the following commands below:

sudo systemctl start nginx                    [On Ubuntu]

sudo systemctl start nginx                    [On CentOS]

Enabling Nginx Service
To enable the Nginx Service to start automatically on system boot, issue the following command below:

sudo systemctl enable nginx                    [On Ubuntu]

sudo systemctl enable nginx                    [On CentOS]

Restarting Nginx Service
To restart the Nginx web server, issue the command below:

sudo systemctl restart nginx                    [On Ubuntu]  

sudo systemctl restart nginx                    [On CentOS]  

Checking Status of Nginx
To check the Nginx service run time status information, issue the following command.

sudo systemctl status nginx                    [On Ubuntu]

sudo systemctl status nginx                    [On CentOS]

Reloading Nginx Service
To reload the Nginx web server configuration after making changes to the Nginx server configuration, issue the command the below:

sudo systemctl reload nginx                    [On Ubuntu]

sudo systemctl reload nginx                    [On CentOS]

Stopping Nginx Service
To stop the Nginx service, issue the following command.

sudo systemctl stop nginx                    [On Ubuntu]

sudo systemctl stop nginx                    [On CentOS]

Removing Nginx
To remove the Nginx web server, issue the following command.

sudo apt remove nginx                    [On Ubuntu]

sudo yum remove nginx                    [On CentOS]