1.首先检查nginx的一些模块需要的其他第三方库的支持:gzip模块需要zlib库,rewrite模块需要pcre库,ssl功能需要openssl库。
yum  -y  install gcc  gcc-c++  autoconf   automake

#tar   xzvf    pcre-8.10.tar.gz
#./configure   --prefix=/usr/local/pcre-enable-utf8   --enable-unicode-properties

2.
#tar   xzvf    nginx-0.X.XX.tar.gz

# cd ngnix-0.X.XX

# 默认安装路径:/usr/local/nginx
./configure    --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/usr/local/nginx/logs/error.log 

--http-log-path=/usr/local/nginx/logs/access.log --pid-path=/usr/local/nginx/var/nginx.pid --lock-path=/usr/local/nginx/var/nginx.lock --http-client-body-temp-

path=/dev/shm/nginx_temp/client_body --http-proxy-temp-path=/dev/shm/nginx_temp/proxy --http-fastcgi-temp-path=/dev/shm/nginx_temp/fastcgi --user=www --group=www --with-cpu-

opt=pentium4F --without-select_module --without-poll_module --with-http_realip_module --with-http_sub_module --with-http_gzip_static_module --without-http_geo_module --without-

http_userid_module --with-http_stub_status_module  --without-http_memcached_module --without-http_map_module --without-mail_pop3_module --without-mail_imap_module --without-

mail_smtp_module --with-pcre=/usr/local/src/pcre-8.10

# make
# sudo  make install
#vim /etc/init.d/nginx   创建启动脚本,加入以下内容。

#!/bin/bash
# chkconfig: - 30 21
# description: http service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings
NGINX_SBIN="/usr/local/nginx/sbin/nginx"
NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/nginx/logs/nginx.pid"
RETVAL=0
prog="Nginx"
start() {
        echo -n $"Starting $prog: "
        mkdir -p /dev/shm/nginx_temp
        daemon $NGINX_SBIN -c $NGINX_CONF
        RETVAL=$?
        echo
        return $RETVAL
}
stop() {
        echo -n $"Stopping $prog: "
        #killproc -p $NGINX_PID $NGINX_SBIN -TERM
        killproc nginx -TERM
        rm -rf /dev/shm/nginx_temp
        RETVAL=$?
        echo
        return $RETVAL
}
reload(){
        echo -n $"Reloading $prog: "
        #killproc -p $NGINX_PID $NGINX_SBIN -HUP
        killproc nginx  -HUP
        RETVAL=$?
        echo
        return $RETVAL
}
restart(){
        stop
        sleep 2
        start
}
configtest(){
    $NGINX_SBIN -c $NGINX_CONF -t
    return 0
}
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  reload)
        reload
        ;;
  restart)
        restart
        ;;
  configtest)
        configtest
        ;;
  *)
        echo $"Usage: $0 {start|stop|reload|restart|configtest}"
        RETVAL=1
esac

exit $RETVAL

#chmod  755 /etc/init.d/nginx  增加执行权限
#
#mkdir /dev/shm/nginx_temp  创建http反向代理缓存文件存放目录
#
#chkconfig --add nginx    增加系统服务
#
#chkconfig --level 3 nginx on    添加随机启动的级别
#
#uuseradd -s /sbin/nologin www  添加用户