1:准备编译安装HAProxy的基础环境
#apt install make gcc build-essential libssl-dev zlib1g-dev libpcre3 libpcre3-dev libsystemd-dev libreadline-dev -y
2:.编译安装lua,为HAProxy支持基于其实现功能扩展。 注:HAProxy要求的lua最低版本为5.3 2.1 下载并且安装lua
# wget -P /usr/local/src/ http://www.lua.org/ftp/lua-5.3.5.tar.gz # cd /usr/local/src/ # tar xf lua-5.3.5.tar.gz # cd lua-5.3.5/src/ # make linux
2.2 查看编译后的版本
root@template-ubuntu-20200606:/usr/local/src/lua-5.3.5/src# ./lua -v Lua 5.3.5 Copyright (C) 1994-2018 Lua.org, PUC-Rio
3.编译安装haproxy 3.1 解压并安装
# cd /usr/local/src/ # tar xf haproxy-2.0.4.tar.gz # cd haproxy-2.0.4 # make -j `lscpu |awk ‘NR==4{print $2}‘` ARCH=x86_64 TARGET=linux-glibc USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1 USE_SYSTEMD=1 USE_CPU_AFFINITY=1 USE_LUA=1 LUA_INC=/usr/local/src/lua-5.3.5/src/ LUA_LIB=/usr/local/src/lua-5.3.5/src/ PREFIX=/apps/haproxy && make install PREFIX=/apps/haproxy
3.2 查看编译安装好的版本信息
root@template-ubuntu-20200606:/usr/local/src/haproxy-2.0.16# ./haproxy -v HA-Proxy version 2.0.16 2020/07/17 - https://haproxy.org/
4.编写haproxy启动脚本