Wednesday, February 1, 2012

How to Install Nginx WebServer


How to Install Nginx Web Server using Yum

Add Nginx yum repository, create a file named /etc/yum.repos.d/nginx.repo and paste one of the configurations below:

For CentOS

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

For Redhat

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

Due to differences between how CentOS, RHEL, and Scientific Linux populate the $releasever variable, it is necessary to manually replace $releasever with either "5" (for 5.x) or "6" (for 6.x), depending upon your OS version.

Now Run following command to install NginX Web Server:

yum -y install nginx

Start NginX Service : service nginx start


How to Install Nginx Web Server using source code

Download stable source code from http://nginx.org/download/nginx-1.0.11.tar.gz

Unzip source code : tar zxvf nginx-1.0.11.tar.gz

Unzipped directory should be nginx-1.0.11:

cd nginx-1.0.11

Run following commands to install:

./configure --prefix=/opt/nginx      (--prefix=[path where to install].... use ./configure --help to find more options to enable or disable features)

make

make install

Start Nginx Web Server : /opt/nginx/bin/nginx
Stop Nginx Web Server : /opt/nginx/bin/nginx -s stop
Nginx Logs and PID file : /opt/nginx/logs/{access.log}{error.log}{nginx.pid}

Thats it!!!

No comments: