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

Installing

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

1
yum install -y wget
yum install -y wget

 

Adding epel repos:

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

1
2
3
4
cd /opt/
wget http://mirrors.nl.eu.kernel.org/fedora-epel/6/i386/epel-release-6-7.noarch.rpm
rpm -Uvh epel-release-6-7.noarch.rpm
rm epel-release-6-7.noarch.rpm -f
cd /opt/
wget http://mirrors.nl.eu.kernel.org/fedora-epel/6/i386/epel-release-6-7.noarch.rpm
rpm -Uvh epel-release-6-7.noarch.rpm
rm epel-release-6-7.noarch.rpm -f

 

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/socket.io@node.js) 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:

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1

 

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:

1
yum install -y nginx
yum install -y nginx

 

Configuring

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…

1
service nginx start
service nginx start

and stop with…

1
service nginx stop
service nginx stop

 

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