Abtest搭建过程

Posted by Clear Blog on May 12, 2018

安装redis

make make test 提示需要tcl 8.5或者newer yum install -y tcl make install

安装nginx

需要提前准备pcre 和 zlib

PCRE(Perl Compatible Regular Expressions) 是一个Perl库, 包括 perl 兼容的正则表达式库。 nginx 的 http 模块使用 pcre 来解析正则表达式, 所以需要在 linux 上安装 pcre 库, pcre-devel 是使用 pcre 开发的一个二次开发库。nginx也需要此库。命令:

yum install -y pcre pcre-devel

zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip ,所以需要在 Centos 上安装 zlib 库。

yum install -y zlib zlib-devel

OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。 nginx 不仅支持 http 协议,还支持 https(即在ssl协议上传输http),所以需要在 Centos 安装 OpenSSL 库。

yum install -y openssl openssl-devel

./configure

make

make install

默认安装在/usr/local/nginx

配置LuaJIT

准备LuaJIT-2.1.0-beta3

make

make installl

ln -sf luajit-2.1.0-beta3 /usr/local/bin/luajit

默认安装路径/usr/local

下载ngx_devel_kit(NDK)https://github.com/simpl/ngx_devel_kit/tags

cd /usr/local/src wget https://github.com/simpl/ngx_devel_kit/archive/v0.2.19.tar.gz tar -xzvf ngx_devel_kit-0.3.1rc1.tar.gz

下载最新的lua-nginx-module 模块 (https://github.com/openresty/lua-nginx-module/tags)

cd /usr/local/src wget https://github.com/openresty/lua-nginx-module/archive/v0.10.2.tar.gz tar -xzvf lua-nginx-module-0.10.12rc2.tar.gz

配置环境变量

export LUAJIT_LIB=/usr/local/lib export LUAJIT_INC=/usr/local/include/luajit-2.1

重新编译nginx

1
2
3
4
5
./configure \
--with-pcre-jit \
--with-ld-opt="-Wl,-rpath,/usr/local/lib/" \
--add-module=/mnt/ngx_devel_kit-0.3.1rc1 \
--add-module=/mnt/lua-nginx-module-0.10.12rc2

如果提示找不到lua lib,则在当前会话中export上面的两个环境变量

make -j2 make install

安装cjson

make 提示找不到lua.h,查看MakeFile的PREFIX 将依赖的文件拷贝到相应文件夹下, cp /usr/local/luajit/include/luajit-2.0/* /usr/local/luajit/include/

启动环境

编写start.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
cd /mnt/ABTestingGateway/utils

/usr/local/bin/redis-server conf/redis.conf &
echo "start redis success"

/usr/local/nginx/sbin/nginx -p `pwd` -c conf/stable.conf
/usr/local/nginx/sbin/nginx -p `pwd` -c conf/beta1.conf
/usr/local/nginx/sbin/nginx -p `pwd` -c conf/beta2.conf
/usr/local/nginx/sbin/nginx -p `pwd` -c conf/beta3.conf
/usr/local/nginx/sbin/nginx -p `pwd` -c conf/beta4.conf

/usr/local/nginx/sbin/nginx -p `pwd` -c conf/nginx.conf
echo "start nginx success"