准备编译安装HAProxy的基础环境
sudo apt install make gcc build-essential libssl-dev zlib1g-dev libpcre3 libpcre3-dev libsystemd-dev libreadline-dev -y
编译安装lua
lua为HAProxy支持基于其实现功能扩展
注:HAProxy要求的lua最低版本为5.3
sudo wget -P /usr/local/src/ http://www.lua.org/ftp/lua-5.3.5.tar.gz
cd /usr/local/src/
sudo tar xf lua-5.3.5.tar.gz
cd lua-5.3.5/src/
sudo make linux
查看编译后的版本
surou@DESKTOP-CRS8RL6:/usr/local/src/lua-5.3.5/src$ ./lua -v
Lua 5.3.5 Copyright (C) 1994-2018 Lua.org, PUC-Rio
编译安装HAProxy
安装基础环境
sudo apt install iproute2 ntpdate tcpdump telnet traceroute nfs-kernel-server nfs-common lrzsz tree openssl libssl-dev libpcre3 libpcre3-dev zlib1g-dev gcc openssh-server iotop unzip libreadline-dev libsystemd-dev
clone haproxy
git clone https://github.com/haproxy/haproxy.git
git checkout v2.3-dev5
编译源代码
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=./dist/haproxy
编译完,查看当前目录
cd dist/haproxy/sbin
查看版本
./haproxy -v
surou@DESKTOP-CRS8RL6:~/dist/haproxy/sbin$ ./haproxy -v
HA-Proxy version 2.3-dev5-7faeea-1 2020/09/26 - https://haproxy.org/
Status: development branch - not safe for use in production.
Known bugs: https://github.com/haproxy/haproxy/issues?q=is:issue+is:open
Running on: Linux 4.4.0-18362-Microsoft #1049-Microsoft Thu Aug 14 12:01:00 PST 2020 x86_64