How to install HAProxy on CentOS 7 Minimal

Afternoon All,

I’ve been asked to install HAProxy on CentOS 7 Minimal however I don’t seem to be able to add/install it. Could someone be so kind and tell me how I can get this added/installed please.

Regards
Andy

You need to have connectivity to the Internet for yum to be able to install haproxy from the repositories.

I have given CentOS 7 access to the internet but when I type “yum install haproxy” I still get the same error message.

Do I need to do something else before I type this command?

You need working connectivity to the Internet, that includes working DNS resolution.

As you can see from the error message above, CentOS is unable to resolve mirrorlist.centos.org:
Could not resolve host: mirrorlist.centos.org

I just figured out how I can install HAProxy, first I had to type the following commands.

1: ONBOOT=no
2: dhclient
3: yum install haproxy

Thanks for your help anyway.

It’s probably worth compiling/installing manually, to get the latest version. It’s pretty straightforward.

It’s not straightforward for everyone at all. The OP in this thread struggled to get the CentOS box connected to the Internet, so I would strongly recommend against compiling from source.

Fair comment. I didn’t have my notes on me at the time but will post them below now, might be of use to someone.

  1. Download the installation files and extract content.

    wget http://www.haproxy.org/download/1.8/src/haproxy-1.8.4.tar.gz
    mkdir haproxy
    tar xzvf haproxy-1.8.4.tar.gz -C haproxy
    cd haproxy/

  2. Install pre-requisites

yum install openssl-devel pcre-devel zlib-devel gcc

  1. Compile source

sudo make TARGET=linux2628 USE_OPENSSL=1 USE_PCRE=1 USE_ZLIB=1

  1. Install and complete installation

    sudo make install
    sudo mkdir -p /etc/haproxy
    sudo mkdir -p /var/lib/haproxy
    sudo touch /var/lib/haproxy/stats
    sudo ln -s /usr/local/sbin/haproxy /usr/sbin/haproxy
    sudo cp examples/haproxy.init /etc/init.d/haproxy
    sudo chmod 755 /etc/init.d/haproxy
    sudo systemctl daemon-reload
    sudo chkconfig haproxy on
    sudo useradd -r haproxy

  2. Start HAProxy and Check the service status

    systemctl start haproxy
    systemctl status haproxy