touch install-nginx.sh

chmod +x install-nginx.sh

vim install-nginx.sh 

#/bin/bash

# auto install  nginx-1.4.2

#author swh

echo  -e  "Nginx will be installing,\nplease wait......"

yum install -y gcc automake autoconf libtool make

yum install -y gcc gcc-c++

yum install -y pcre* zlib*  openssl*

mkdir  /usr/local/nginx

groupadd nginx

useradd  -r nginx -g  nginx -s /sbin/nologin

chown  -R nginx:nginx  /usr/local/nginx

wget http://nginx.org/download/nginx-1.4.2.tar.gz

tar -zxvf nginx-1.4.2.tar.gz

cd nginx-1.4.2

./configure --prefix=/usr/local/nginx  --user=nginx  --group=nginx --with-http_ssl_module

make && make install

echo  "Nginx install over,Now checking....."

/usr/local/nginx/sbin/nginx

netstat  -tuplna  |  grep  nginx

ps -ef | grep nginx

ret=$?

if [ $ret  -eq 0 ]

       then

       echo  "Nginx install sucess"

       echo;echo

       echo "`/usr/local/nginx/sbin/nginx -V`"

elif [ $ret -ne 0 ]


netstat -tuplna | grep nginx

tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      4515/nginx  

[root@localhost ~]# ps -ef |grep nginx

root      4515     1  0 10:36 ?        00:00:00 nginx: master process /home/nginx/sbin/nginx

www       4518  4515  0 10:36 ?        00:00:00 nginx: worker process 

root     11787  2201  0 11:24 pts/0    00:00:00 grep nginx