1] Download source code of Nginx from the official site (http://nginx.net/)
To get stable version as per this tutorial dated is
$ wget http://sysoev.ru/nginx/nginx-0.7.61.tar.gz
or
To get development version as per this tutorial dated is
$ wget http://sysoev.ru/nginx/nginx-0.8.7.tar.gz
(Note : For production server use stable version only)
2] We store downloaded file under a directory, for example we will use 'download' directory
$ mkdir ~/download
$ cp nginx-0.6.36.tar.gz ~/download
$ cd download
3] Install required Nginx dependencies
pcre pcre-devel zlib zlib-devel openssl openssl-devel
so using default package manager of CentOS
$ sudo yum install pcre pcre-devel zlib zlib-devel openssl openssl-devel
4] Create required Nginx user and group ids
$ sudo /usr/sbin/groupadd nginx
$ sudo /usr/sbin/useradd –g nginx –s /bin/false nginx
5] Proceed with source installation of Nginx
$ cd ~/download
unzip the source file
$ tar -zxvf nginx-0.7.61.tar.gz
$ cd nginx-0.7.61
6] Configure Nginx source
$ ./configure \
--prefix=/usr/local/nginx \
--sbin-path=/usr/local/sbin \
--conf-path=/usr/local/nginx/nginx.conf \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=nginx \
--group=nginx \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_perl_module \
--with-http_flv_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-md5-asm \
--with-md5=auto/lib/md5 \
--with-sha1-asm \
--with-sha1=auto/lib/sha1
7] Make and Install
$ make
$ sudo make install
8] Change ownerships before we proceed
$ sudo chown nginx:nginx –R /usr/local/nginx
9] Create following directories with required ownership to proceed
$ sudo mkdir -p /var/tmp/nginx /{client,proxy,fcgi}
$ sudo chown nginx:nginx -R /var/tmp/nginx
10] Start Nginx
$ sudo /usr/local/sbin/nginx
If we get no error while starting Nginx then lets check running process status by executing following command and getting similar output as below
$ ps aux | grep nginx
root 10009 0.0 0.0 5524 592 ? Ss 07:21 0:00 nginx: master process /usr/local/sbin/nginx
nginx 10010 0.0 0.0 5716 928 ? S 07:21 0:00 nginx: worker process
11] And we are ready to use Nginx
Open your browser and type ip address of your server or just type localhost.
http://localhost
http://127.0.0.1
Bingo!!!
12] Shutdown Nginx
$ sudo kill `cat /var/run/nginx/nginx.pid`
No comments:
Post a Comment