Nginx is a popular lightweight server for those who do not need the bulk and extra services that Apache may offer. This article will look at installing Nginx on a CentOS using the ‘yum’ package manager.
YUM is the inbuilt package manager to install packages and remove too. Installing via YUM is a very easy it solves dependency issues and you are assured of any security updates if, and when, they occur.
Here is the Step by Step configuration for YUM locally . Here We are going to use Extra Packages for Enterprise Linux(EPEL) for installing Nginx.
To install Nginx using yum we need to include the EPEL (Extra Packages for Enterprise Linux) repository. This repository was developed by the Fedora community to provide extra add-on packages for Fedora-based Redhat Enterprise Linux and its compatible to CentOS.
EPEL repository only provides additional packages that are not provided by the default repositories.
First install the EPEL repository.
Update the YUM repository.
Once updated the YUM repo’s, install the Nginx by invoking the following command.
If you are installing the rpm from EPEL repository for the first time it will be prompt for importing the gpg keys. Type Yes to import.
This key is used to sign all packages that are associated with the EPEL repository to verify their validity. Once the gpg-key is imported, yum will start to install RPM’s.
Once installed. Start the Nginix by using the following command.
Once started. Navigate the web browser to Nginx server(IP Address or Host Name). The following image shows the default Welcome Screen of Nginx.
Init scripts will help you to start and stop the service. The init scripts for the Nginx installed automatically while installing Nginx.
However, we need to set up Nginx to start automatically if the server is rebooted:
Controlling the Nginx using the following command.