Install Nginx on CentOS 7.7 Azure VM

In this blog post, I will show you how to install Nginx Web server on Centos 7.7 Azure VM.

Last week I deployed an Azure VM running Centos 7.7 that will act as a web server.

Add Repository

The first step I will take in the installation process is to add Nginx repository to the OS.

I will do it by creating a repo file using the nano text editor.

sudo nano /etc/yum.repos.d/nginx.repo

After creating the file, I will add the following like to it.

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

Install Nginx

After I saved the file, I will run the installation command shown below.

sudo yum install nginx

Auto Start

To autostart Nginx every time the VM starts I will use the command below:

sudo systemctl enable nginx

Start Nginx

By default, Nginx is not running after installation, and I will start it using the command below:

sudo systemctl start nginx

Note: to stop Nginx I will use the following command:

sudo systemctl stop nginx

Test

If I browse to my Azure public IP, I will see the Nginx welcome page.

Processing…
Success! You're on the list.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.