Installing nginx on Centos 6.3

nginx on Centos

What is nginx

nginx [engine x] is an HTTP and reverse proxy server, as well as a mail proxy server, written by Igor Sysoevread more


if you don’t have wget, please install it before:

[code lang=”bash”]yum install -y wget[/code]


Adding epel repos:

if you don’t have the epel repos for your centos, you should do it now.

[code lang=”bash”]cd /opt/
rpm -Uvh epel-release-6-7.noarch.rpm
rm epel-release-6-7.noarch.rpm -f[/code]


Adding nginx repos:

as for the time being of writing this article, epel repo nginx’s version is lower then 1.1 (which needed for some of you – using http1.1 functions like websockets/ you can use the nginx repos to install more updated version of nginx:

To add nginx yum repository, create a file named /etc/yum.repos.d/nginx.repo and paste the configurations below:

name=nginx repo


One small thing: the epel repos installs more attractive default page (/usr/share/nginx/html) and three confs (/etc/nginx/conf.d)
I just backuped the confs, moved the htmls to /var/www/nginx/html and then ‘yum update’ from nginx repo and put them back 🙂 


Installing nginx

As simple as:
[code lang=”bash”]yum install -y nginx[/code]



the nginx conf files located at: ‘/etc/nginx/conf.d’.

you have three templates:

  • default.conf
  • ssl.conf
  • virtual.conf

Start/Stop service

start service with…

[code lang=”bash”]service nginx start[/code]

and stop with…

[code lang=”bash”]service nginx stop[/code]


after service start, you can browse to the machine and see it’s default hosted page (/usr/share/nginx/html)