Nginx负载均衡优化插件编译及配置
来源:互联网 发布:drenched 知乎 编辑:程序博客网 时间:2024/05/12 08:07
一、 Ngix依赖模块安装
Ngix依赖模块有:pcre、zlib、openssl、md5 /sha1(如果系统中没有安装相应模块,需要按照下列方式安装)
1、 安装pcre模块(8.35)
官方网站:http://www.pcre.org/
安装命令:
# unzip pcre-8.35.zip
# cd pcre-8.35
# ./configure
# make && make install
在64位linux系统中,nginx搜索的库位置为lib64;所以,需要建立软连接:
# ln -s /usr/local/lib/libpcre.so.1 /lib64/
# ln -s /usr/local/lib/libpcre.so.1 /lib/
# ln -s /usr/local/lib/libpcre.so.1 /usr/local/lib64/
2、 安装zlib模块(1.2.8)
官方网站:http://www.zlib.net/
安装命令:
# tar zxvf zlib-1.2.8.tar.gz
# cd zlib-1.2.8
# ./configure
# make && make install
3、 安装openssl模块(1.0.1h)
官方网站:http://www.openssl.org/
安装命令:
# tar zxvf openssl-1.0.1h.tar.gz
# cd openssl-1.0.1h
# ./config
# make &&make install
4、 解压Nginx插件
1) nginx_upstream_hash插件
负载均衡Hash策略插件。
官方网站:https://github.com/evanmiller/nginx_upstream_hash
# unzip nginx_upstream_hash-master.zip
2) nginx-sticky-module插件
负载均衡基于cooki的会话粘合插件,反向代理会话指向相同后端服务器。注:官方下载的源码,在源代码ngx_http_sticky_module.c中的295行代码编译错误,需要将第295行的 ngx_http_sticky_srv_conf_t *conf = iphp->sticky_conf; 放到第297行。
官方网站:https://github.com/yaoweibin/nginx-sticky-module
# unzip nginx-sticky-module-master.zip
3) ngx_pagespeed插件
前端网页访问提速优化插件。
官方网站:https://github.com/pagespeed/ngx_pagespeed
https://dl.google.com/dl/page-speed/psol/1.8.31.4.tar.gz
# unzip ngx_pagespeed-master.zip
# cp 1.8.31.4.tar.gz ./ngx_pagespeed-master
# cd ngx_pagespeed-master
# tar -xzvf 1.8.31.4.tar.gz
二、 Nginx安装
1、 安装Nginx(1.6.0)
官方网站:http://nginx.org/
安装命令:
# tar zxvf nginx-1.6.0.tar.gz
# cd nginx-1.6.0
# ./configure --user=TSP \
--prefix=/usr/local/nginx \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_realip_module \
--add-module=/home/TSP/nginx/plugin/nginx_upstream_hash-master \
--add-module=/home/TSP/nginx/plugin/nginx-sticky-module-master \
--add-module=/home/TSP/nginx/plugin/ngx_pagespeed-master
# make && make install
安装完成后的Nginx的目录结构:
[root@AP nginx-1.6.0]# ll /usr/local/nginx/
total 16
drwxr-xr-x 2 root root 4096 Jun 24 14:42 conf
drwxr-xr-x 2 root root 4096 Jun 24 14:42 html
drwxr-xr-x 2 root root 4096 Jun 24 14:42 logs
drwxr-xr-x 2 root root 4096 Jun 24 14:42 sbin
2、 修改配置文件中的监听端口,确保不被其他程序占用
修改配置文件:/usr/local/nginx/conf/nginx.conf
修改端口:80->9090
2.1、设置Linux防火墙,打开端口9090
执行命令:
# /sbin/iptables -I INPUT -p tcp --dport 9090 -j ACCEPT
保存设置命令:
# /etc/rc.d/init.d/iptables save
查看端口打开情况命令:
#/etc/init.d/iptables status
重启防火墙服务
# /etc/rc.d/init.d/iptables restart
3、 启动、停止Nginx
A、 启动命令
#/usr/local/nginx/sbin/nginx
B、 停止命令
# /usr/local/nginx/sbin/nginx -s stop
C、 检查配置文件
# /usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
D、 查看nginx版本及完整版本
# /usr/local/nginx/sbin/nginx –V
nginx version: nginx/1.6.0
# /usr/local/nginx/sbin/nginx –V
nginx version: nginx/1.6.0
built by gcc 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC)
configure arguments: --prefix=/usr/local/nginx --with-openssl=/usr/local/openssl --with-http_stub_status_module
Ngix依赖模块有:pcre、zlib、openssl、md5 /sha1(如果系统中没有安装相应模块,需要按照下列方式安装)
1、 安装pcre模块(8.35)
官方网站:http://www.pcre.org/
安装命令:
# unzip pcre-8.35.zip
# cd pcre-8.35
# ./configure
# make && make install
在64位linux系统中,nginx搜索的库位置为lib64;所以,需要建立软连接:
# ln -s /usr/local/lib/libpcre.so.1 /lib64/
# ln -s /usr/local/lib/libpcre.so.1 /lib/
# ln -s /usr/local/lib/libpcre.so.1 /usr/local/lib64/
2、 安装zlib模块(1.2.8)
官方网站:http://www.zlib.net/
安装命令:
# tar zxvf zlib-1.2.8.tar.gz
# cd zlib-1.2.8
# ./configure
# make && make install
3、 安装openssl模块(1.0.1h)
官方网站:http://www.openssl.org/
安装命令:
# tar zxvf openssl-1.0.1h.tar.gz
# cd openssl-1.0.1h
# ./config
# make &&make install
4、 解压Nginx插件
1) nginx_upstream_hash插件
负载均衡Hash策略插件。
官方网站:https://github.com/evanmiller/nginx_upstream_hash
# unzip nginx_upstream_hash-master.zip
2) nginx-sticky-module插件
负载均衡基于cooki的会话粘合插件,反向代理会话指向相同后端服务器。注:官方下载的源码,在源代码ngx_http_sticky_module.c中的295行代码编译错误,需要将第295行的 ngx_http_sticky_srv_conf_t *conf = iphp->sticky_conf; 放到第297行。
官方网站:https://github.com/yaoweibin/nginx-sticky-module
# unzip nginx-sticky-module-master.zip
3) ngx_pagespeed插件
前端网页访问提速优化插件。
官方网站:https://github.com/pagespeed/ngx_pagespeed
https://dl.google.com/dl/page-speed/psol/1.8.31.4.tar.gz
# unzip ngx_pagespeed-master.zip
# cp 1.8.31.4.tar.gz ./ngx_pagespeed-master
# cd ngx_pagespeed-master
# tar -xzvf 1.8.31.4.tar.gz
二、 Nginx安装
1、 安装Nginx(1.6.0)
官方网站:http://nginx.org/
安装命令:
# tar zxvf nginx-1.6.0.tar.gz
# cd nginx-1.6.0
# ./configure --user=TSP \
--prefix=/usr/local/nginx \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_realip_module \
--add-module=/home/TSP/nginx/plugin/nginx_upstream_hash-master \
--add-module=/home/TSP/nginx/plugin/nginx-sticky-module-master \
--add-module=/home/TSP/nginx/plugin/ngx_pagespeed-master
# make && make install
安装完成后的Nginx的目录结构:
[root@AP nginx-1.6.0]# ll /usr/local/nginx/
total 16
drwxr-xr-x 2 root root 4096 Jun 24 14:42 conf
drwxr-xr-x 2 root root 4096 Jun 24 14:42 html
drwxr-xr-x 2 root root 4096 Jun 24 14:42 logs
drwxr-xr-x 2 root root 4096 Jun 24 14:42 sbin
2、 修改配置文件中的监听端口,确保不被其他程序占用
修改配置文件:/usr/local/nginx/conf/nginx.conf
修改端口:80->9090
2.1、设置Linux防火墙,打开端口9090
执行命令:
# /sbin/iptables -I INPUT -p tcp --dport 9090 -j ACCEPT
保存设置命令:
# /etc/rc.d/init.d/iptables save
查看端口打开情况命令:
#/etc/init.d/iptables status
重启防火墙服务
# /etc/rc.d/init.d/iptables restart
3、 启动、停止Nginx
A、 启动命令
#/usr/local/nginx/sbin/nginx
B、 停止命令
# /usr/local/nginx/sbin/nginx -s stop
C、 检查配置文件
# /usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
D、 查看nginx版本及完整版本
# /usr/local/nginx/sbin/nginx –V
nginx version: nginx/1.6.0
# /usr/local/nginx/sbin/nginx –V
nginx version: nginx/1.6.0
built by gcc 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC)
configure arguments: --prefix=/usr/local/nginx --with-openssl=/usr/local/openssl --with-http_stub_status_module
0 0
- Nginx负载均衡优化插件编译及配置
- nginx安装及负载均衡配置
- Nginx安装及负载均衡配置
- ubuntu安装nginx及负载均衡配置
- CentOs nginx 安装 及 负载均衡配置
- nginx 负载均衡策略及配置
- nginx负载均衡及主备配置
- nginx 负载均衡配置
- nginx配置负载均衡
- nginx负载均衡配置
- Nginx负载均衡配置
- Nginx负载均衡配置
- Nginx负载均衡配置
- nginx负载均衡配置
- Nginx 负载均衡配置
- nginx负载均衡配置
- nginx负载均衡配置
- nginx负载均衡配置
- LeetCode-Search in Rotated Sorted Array
- 回调模式
- struts2学习 cookie整理
- 各种排序总结
- 数组简单排序——冒泡法与选择排序法
- Nginx负载均衡优化插件编译及配置
- 达内2013C++教程笔记(其实为其数据结果与算法的一部分,但内容更像是C++的)
- 神奇的图形反思一个新教师
- lucene包的下载地址
- Hadoop集群安全性:Hadoop中Namenode单点故障的解决方案及详细介绍AvatarNode
- 安装Ubuntu的Mozilla Firefox的Adobe Flash Player时学习/lib、/usr/lib、/usr/local/lib的区别
- 安卓创建快捷方式相关问题 Intent Intent-filter
- git的远程分支和跟踪分支初探
- IOS中类和对象还有,nil/Nil/NULL的区别