In this tutorial, we will show you how to Install Nginx using yum command on CentOS systems. For those of you who didn’t know, Nginx is one of the most popular web servers in the world and is responsible for hosting some of the largest and highest-traffic sites on the internet. It is more resource-friendly than Apache in most cases and can be used as a web server or a reverse proxy.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. So today I’m going to show you how to setup Nginx web server on CentOS systems. It’s really not that difficult. Let’s start with Nginx.
Install Nginx Using Yum Command on CentOS
Step 1. First, let’s start by ensuring your system is up-to-date.
sudo yum clean all sudo yum update
Step 2 Installing Nginx Using
Yum Command on CentOS.
To install, first, you must add the Webtatic yum repository information corresponding to your CentOS/RHEL version to yum:
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
Install Nginx package and dependencies using the below command :
yum install nginx16
To start the Nginx server, issue the following command:
service nginx start
To stop the Nginx server, issue the following command:
service nginx stop
- The main configuration file for Nginx is
- Virtual hosts are defined in
- PHP will be configured in
Before you close that terminal window, it’s necessary to set the Nginx service to start at boot. Just issue the following command:
chkconfig nginx on
Navigating to your Server’s IP address (assuming you have no other server listening on port 80), you will be greeted with the standard welcome page:
The steps above should produce a running Nginx which serves the Nginx default pages on port 80. We’ll start working through various configurations and optimizations to round out the series. Enjoy your new webserver!
Congratulations! You have successfully installed Nginx. Thanks for using this tutorial for installing Nginx web server in CentOS system. For additional help or useful information, we recommend you to check the official Nginx website.