How to install Nginx on RHEL/CentOS

Step 1: Install Nginx

Nginx is well known web server. Download and install nginx repos:

For RedHat

# wget
# rpm -ivh nginx-release-rhel-6-0.el6.ngx.noarch.rpm

For CentOS

# wget
# rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm
# yum --enablerepo=epel -y install nginx

Step 2: Configure Nginx

Edit the nginx.conf file to configure Nginx.

# vi /etc/nginx/nginx.conf
worker_processes 2
gzip on;
# cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/
# egrep -v "^ *#|^ *$" /etc/nginx/conf.d/ > /etc/nginx/conf.d/default.conf

Edit default.conf file and enter the server name

# vi /etc/nginx/conf.d/default.conf
server_name www.example-server

Step 3: Start nginx Server

After configuration has made, restart nginx service.

# service nginx start 
#/etc/rc.d/init.d/nginx start
Starting nginx: [ OK ]
# chkconfig nginx on

Step 4: Open Page on Browser

Hit the Server IP on your favorite browser, a default page of nginx appears:


0 0 vote
Article Rating
Notify of
Inline Feedbacks
View all comments