在服务器快速集群环境搭建中,都迫切需要一个能拿来即用的负载均衡器,nginx在1.9版本之前,只支持http协议web服务器的负载均衡,从1.9版本开始以后,nginx开始支持tcp的长连接负载均衡,但是nginx默认并没有编译tcp负载均衡模块,编写它时,需要加入–with-stream参数来激活这个模块。
nginx编译加入–with-stream参数激活tcp负载均衡模块
nginx编译安装需要先安装pcre、openssl、zlib等库,也可以直接编译执行下面的configure命令,根据错误提示信息,安装相应缺少的库。
下面的make命令会向系统路径拷贝文件,需要在root用户下执行
[root@localhost nginx-1.18.0]# ./configure --with-cc=/apps/sylar/bin/gcc --with-stream
checking for OS
+ Linux 3.10.0-1160.el7.x86_64 x86_64
checking for C compiler ... found
+ using GNU C compiler
+ gcc version: 9.1.0 (GCC)
[root@localhost nginx-1.18.0]# make && make install
编译完成后,默认安装在了/usr/local/nginx目录。
[root@localhost sbin]# cd /usr/local/nginx/
[root@localhost nginx]# ls
client_body_temp fastcgi_temp logs sbin uwsgi_temp
conf html proxy_temp scgi_temp
错误1:./configure: error: C compiler cc is not found
很明显在编译过程中没有发现 C 语言编译器(checking for C compiler ... not found
)
[root@localhost nginx-1.18.0]# ./configure --with-stream
checking for OS
+ Linux 3.10.0-1160.el7.x86_64 x86_64
checking for C compiler ... not found
./configure: error: C compiler cc is not found
只需要在编译选项中指定C编译器即可:--with-cc=/apps/sylar/bin/gcc
。
./configure --with-cc=/apps/sylar/bin/gcc --with-stream
checking for OS
+ Linux 3.10.0-1160.el7.x86_64 x86_64
checking for C compiler ... found
+ using GNU C compiler
+ gcc version: 9.1.0 (GCC)