- nginx sticky模块安装是C语言和per脚本写的.因此需要安装gcc和g++编译器
- 安装sticky模块需要首先安装zlib库.
- 安装perl库.
- 安装openssl库
这个会出现错误
Can't locate CPAN.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .).
BEGIN failed--compilation aborted.
执行
yum -y install perl-CPAN
继续执行
./Configure --prefix=/usr/local/ssl --openssldir=/usr/local/ssl '-Wl,-rpath,$(LIBRPATH)'
出现
Can't locate IPC/Cmd.pm in @INC (@INC contains: /root/nginx/openssl-3.0.0-alpha16/util/perl /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 . /root/nginx/openssl-3.0.0-alpha16/external/perl/Text-Template-1.56/lib) at /root/nginx/openssl-3.0.0-alpha16/util/perl/OpenSSL/config.pm line 18.
BEGIN failed--compilation aborted at /root/nginx/openssl-3.0.0-alpha16/util/perl/OpenSSL/config.pm line 18.
Compilation failed in require at ./Configure line 23.
BEGIN failed--compilation aborted at ./Configure line 23.
执行
perl -MCPAN -e shell install Log::Log4perl install HTML::TokeParser::Simple
yum -y install perl-IPC-Cmd.noarch
全部按yes完成
继续执行
./Configure --prefix=/usr/local/ssl --openssldir=/usr/local/ssl '-Wl,-rpath,$(LIBRPATH)'
生成makefile 成功
继续执行
make && make install
下载stick模块
get https://bitbucket.org/nginx-goodies/nginx-sticky-module-ng/get/master.tar.gz
tar zxf master.tar.gz
cd nginx-goodies-nginx-sticky-module-ng-08a395c66e42
下载nginx源代码1.16.1
wget http://nginx.org/download/nginx-1.16.1.tar.gz
tar zxf nginx-1.16.1.tar.gz
cd nginx-1.16.1
编译
./configure --prefix=/opt/nginx --add-module=../nginx-goodies-nginx-sticky-module-ng-08a395c66e42 --with-http_stub_status_module --with-http_ssl_module
如果遇到定义错误
vi ../nginx-goodies-nginx-sticky-module-ng-08a395c66e42/ngx_http_sticky_misc.c
在头文件修改
继续编译
yum -y install openssl-devel
make &&make install
安装成功
测试,增加如下代码,重新启动nginx,注意,这个需要在/opt/nginx/sbin/nginx启动