一.基本环境

  nginx 1.9版以后增加了一些新的特性,支持tcp负载均衡,不过这次还是用1.8.0,这里面有个memcached的代理模块,有时间再测试下

1.centos6.6

2.nginx1.8.0.tar.gz

 

二.安装

 

nginx缺省模块

--without-select_module   disable select module    #用来支持select模型
--without-poll_module     disable poll module        #用来支持poll模型
--without-http_charset_module   disable ngx_http_charset_module  #用来支持各种编码模块
--without-http_gzip_module  disable ngx_http_gzip_module       #用来支持压缩的模块
--without-http_ssi_module    disable ngx_http_ssi_module     
--without-http_userid_module  disable ngx_http_userid_module
--without-http_access_module  disable ngx_http_access_module
--without-http_auth_basic_module  disable ngx_http_auth_basic_module    #支持基本验证的模块
--without-http_autoindex_module  disable ngx_http_autoindex_module
--without-http_geo_module  disable ngx_http_geo_module
--without-http_map_module  disable ngx_http_map_module
--without-http_split_clients_module  disable ngx_http_split_clients_module
--without-http_referer_module   disable ngx_http_referer_module         #通过referer可验证来源地址是否一致
--without-http_rewrite_module  disable ngx_http_rewrite_module         #重写模块
--without-http_proxy_module  disable ngx_http_proxy_module           #反向代理模块
--without-http_fastcgi_module  disable ngx_http_fastcgi_module           #用来支持fastcgi
--without-http_uwsgi_module  disable ngx_http_uwsgi_module            #用来支持uwsgi
--without-http_scgi_module  disable ngx_http_scgi_module               #用来支持scgi

--without-http_memcached_module  disable ngx_http_memcached_module    #memcached代理模块
--without-http_limit_conn_module  disable ngx_http_limit_conn_module      #用来限制连接数的模块
--without-http_limit_req_module  disable ngx_http_limit_req_module         #用来限制请求数的模块
--without-http_empty_gif_module disable ngx_http_empty_gif_module       #用来生成一张1x1的空白图片,可用来传递参数
--without-http_browser_module  disable ngx_http_browser_module   #用来匹配浏览器头部的模块
--without-http_upstream_hash_module     disable ngx_http_upstream_hash_module    #根据hash算法负载均衡
--without-http_upstream_ip_hash_module   disable ngx_http_upstream_ip_hash_module   #根据ip hash算法负载均衡
--without-http_upstream_least_conn_module  disable ngx_http_upstream_least_conn_module   #最少连接数负载均衡
--without-http_upstream_keepalive_module   disable ngx_http_upstream_keepalive_module   #用来支持长连接的模块,也就是连接复用
--without-http   disable HTTP server     #用来支持http服务器的模块
--without-http-cache   disable HTTP cache   #用来支持http缓存的模块
--without-mail_pop3_module disable ngx_mail_pop3_module    #用来支持代理邮件pop3收件协议的模块
--without-mail_imap_module disable ngx_mail_imap_module  #用来支持代理邮件imap收件协议的模块
--without-mail_smtp_module  disable ngx_mail_smtp_module  #用来支持代理邮件smtp发件协议的模块
--without-pcre  disable PCRE library usage    #用来支持正则的模块

 

#现在选取几个常用的模块 nginx状态监控和一个ssl模块

$ yum install -y wget pcre pcre-devel zlib zlib-devel openssl openssl-devel
$ useradd nginx -s /sbin/nologin -M
$ ./configure --prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module 
--with-http_ssl_module

$ make && make install
$ ln -s /usr/local/nginx/sbin/nginx /usr/sbin/
$ ln -s /usr/local/nginx/conf /etc/nginx

  

  

 

三.配置

$ touch /etc/init.d/nginx
$ chmod 755 /etc/init.d/nginx 
$ vi /etc/init.d/nginx
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.0.0.2 version.
# chkconfig: - 85 15
# description: Nginx is a high-performance web and proxy server.
#              It has a lot of features, but it's not for everyone.
# processname: nginx
# pidfile: /var/run/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf
nginxd=/usr/local/nginx/sbin/nginx
nginx_config=/usr/local/nginx/conf/nginx.conf
nginx_pid=/usr/local/nginx/logs/nginx.pid
RETVAL=0
prog="nginx"
# Source function library.
.  /etc/rc.d/init.d/functions
# Source networking configuration.
.  /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x $nginxd ] || exit 0
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ];then
   echo "nginx already running...."
   exit 1
fi
   echo -n $"Starting $prog: "
   daemon $nginxd -c ${nginx_config}
   RETVAL=$?
   echo
   [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
   return $RETVAL
}
# Stop nginx daemons functions.
stop() {
        echo -n $"Stopping $prog: "
        killproc $nginxd
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /usr/local/nginx/logs/nginx.pid
}
reload() {
    echo -n $"Reloading $prog: "
    #kill -HUP `cat ${nginx_pid}`
    killproc $nginxd -HUP
    RETVAL=$?
    echo
}
# See how we were called.
case "$1" in
start)
        start
        ;;
stop)
        stop
        ;;
reload)
        reload
        ;;
restart)
        stop
        start
        ;;

status)
        status $prog
        RETVAL=$?
        ;;
*)
        echo $"Usage: $prog {start|stop|restart|reload|status|help}"
        exit 1
esac
exit $RETVAL

  

四.启动

 /etc/init.d/nginx start

Centos6.6 编译安装nginx

五.检查

Centos6.6 编译安装nginx

 

Centos6.6 编译安装nginx

 

结束!!!!