Installing Nginx
Follow these steps to install Nginx:
Step 1 : Update the apt package repository and install Nginx.
Step 2 : Check if Nginx is properly installed and running
Step 3 : Check the installed version of Nginx
Step 4 : Open a browser on a local machine and point it to the server IP address.
Configuring Nginx Server Block (Virtual host)
Step 5 : Change the directory to /var/www and create a directory structure for the required domains and sub-domain. Also create a blank index.html for each domain
Step 6 : Change the directory ownership and file permissions on the newly created directories
Step 7 : Edit the index.html
Step 8 : Next, we need to create virtual host configuration for each domain. Change the directory to /etc/nginx/sites-available and copy the default virtual host file default
Step 9 : Edit the new virtual host file
Step 10 : Let’s enable the file by creating a link from it to the sites-enabled directory
Step 11 : To test the Nginx configuration, run the following command
Step 12 : Restart Nginx to enable your changes
Step 13 : Finally, try to access domains by their names. You should see text entered in the respective index.html files for each domain: