Nginx, an acronym for ‘enginex’ is an HTTP and reverse proxy server, as well as a mail proxy server. It is available from the Nginx repo as well as the Epel repo, so here we will use the Nginx repo. The rpm repo pack contains the GPG key needed to authenticate the signed rpms. This guide covers the basic installation on Centos 6 with minimal edits to get up and running, it does not cover more advanced configuration.
I give it priority 40 and disable epel when installing it.

First download the repo pack using wget

$ sudo yum -y install wget

Centos 6 users

$ sudo wget

RHEL users

$ sudo wget

$ sudo rpm -Uvh nginx-release-rhel-6-0.el6.ngx.noarch.rpm
Once its installed we configure it

$ sudo chkconfig nginx on

Edit the config files

$ sudo vi /etc/nginx/nginx.conf

Find your cpu count

$ lscpu | grep CPU

worker_processes 2;   (set to number of cpus)

gzip on;              (uncomment)

$ sudo vi /etc/nginx/conf.d/default.conf

listen        80; 

server_name   localhost

Now start the server

$ sudo service nginx start

Starting nginx:                                      [  OK ] 

Other commands

$ sudo service nginx stop

$ sudo service nginx restart

$ sudo service nginx status

$ sudo service nginx reload

Check it is started and running

$ sudo netstat -tulpn | grep :80
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0  *                   LISTEN      –                  
anton.Centos.~>ps aux | grep nginx
anton     2842  0.0  0.1  45604 10232 ?        Ss   18:35   0:01
root      3225  0.0  0.0   7416   828 ?        Ss   19:01   0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx     3226  0.0  0.0   7596  1204 ?        S    19:01   0:00 nginx: worker process                  
nginx     3227  0.0  0.0   7596  1228 ?        S    19:01   0:00 nginx: worker process                  
anton     3234  0.0  0.0   4356   756 pts/2    S+   19:01   0:00 

Now browse to http://localhost as in the image above.


The above was done without setting any firewall rules but others may have to set rules in iptables, if so it will probably be something similar to below.

$ sudo vi /etc/sysconfig/iptables

Enter into the file

-A INPUT -m state –state NEW -p tcp –dport 80 -j ACCEPT

$ sudo iptables restart 

More repos


Author: Paul Anthony McGowan

Web Technology & Linux Enthusiast, Javascript Afficiado, General Observer Of World Corruption. Builder Of A Variety Of Web Properties And Campaigner Against Serious Government Criminality. Founder of Vorteasy

Leave a Reply

Your email address will not be published. Required fields are marked *