Tuesday, November 22, 2011

Revisiting Nginx (engine x) – Installation Guide on CentOS 5.5

It has been a long time since I worked with Nginx and decide to check it again. And was amazed to find that the server has improved and also its installation process is much simpler. Below are the revised installation steps.

1] Download Nginx from its official site (http://nginx.org/)

Stable version is available at

(Note : On production server use only stable version)

or

Development version is available at



2] Lets store downloaded file under a directory, for example 'download' directory

$ mkdir ~/download

$ mv nginx-1.0.10.tar.gz ~/download


3] We need to install following required Nginx dependencies - pcre pcre-devel zlib zlib-devel openssl openssl-devel

$ sudo yum install pcre pcre-devel zlib zlib-devel openssl openssl-devel


4] Create Nginx user and group id

$ sudo /usr/sbin/groupadd nginx

$ sudo /usr/sbin/useradd –g nginx –s /bin/false nginx


5] Proceed with source installation of Nginx

$ cd ~/download

$ tar -zxvf nginx-1.0.10.tar.gz

$ cd nginx-1.0.10.tar.gz


6] Configure Nginx source

$ ./configure \
--user=nginx \
--group=nginx \
--with-http_realip_module \
--with-http_flv_module \
--with-http_gzip_static_module \
--with-http_ssl_module \
--with-http_stub_status_module


7] Make and install

$ make

$ sudo make install


8] Change ownerships before we proceed

$ sudo chown nginx:nginx –R /usr/local/nginx


9] To start Nginx

$ sudo /usr/local/nginx/sbin/nginx

If we get no error while starting Nginx then lets check running process status

[joel@localhost ~]$ ps aux | grep nginx
root 14802 0.0 0.0 4076 500 ? Ss 01:27 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 14803 0.0 0.1 4264 1092 ? S 01:27 0:00 nginx: worker process
joel 15004 0.0 0.0 4016 708 pts/1 S+ 01:39 0:00 grep nginx

10] And now we are ready to use Nginx

Open http://localhost or http://127.0.0.1 on your system browser and Nginx shows up.

Bingo!!!

11] To shutdown Nginx

$ sudo kill `cat /usr/local/nginx/logs/nginx.pid`