Compiling and Installing HAProxy from Source Code
- Obtain the HAProxy source code.
- Download the HAProxy source code package using a local browser.
Download address: https://www.haproxy.org/download/1.9/src/haproxy-1.9.0.tar.gz
- Copy the source code to the /home directory on the server.
If the server is connected to the Internet, you can run the wget command on the server to download the source code.
1cd /home
1wget https://www.haproxy.org/download/1.9/src/haproxy-1.9.0.tar.gz --no-check-certificate
- Download the HAProxy source code package using a local browser.
- Switch to the home directory.
1cd /home/
- Decompress the HAProxy package.
1tar -xzvf haproxy-1.9.0.tar.gz

- Switch to the haproxy-1.9.0 directory.
1cd /home/haproxy-1.9.0/
- Compile and install HAProxy.
1make TARGET=linux41 && make install PREFIX=/usr/local/haproxy/
PREFIX=PATH specifies the HAProxy installation directory.
- Create a folder in the HAProxy installation path for storing the configuration file.
1mkdir -p /usr/local/haproxy/conf
- Copy the configuration file from the source code directory to the installation directory.
1cp /home/haproxy-1.9.0/examples/*.cfg /usr/local/haproxy/conf/
- Check the installation directory.
1ll /usr/local/haproxy
Parent topic: Installing HAProxy