Skip to content

Instantly share code, notes, and snippets.

@thyn
Forked from ryzy/a.sh
Last active July 25, 2022 22:15
Show Gist options
  • Save thyn/1c3f5efb0fa5e75b7284c507e146db93 to your computer and use it in GitHub Desktop.
Save thyn/1c3f5efb0fa5e75b7284c507e146db93 to your computer and use it in GitHub Desktop.
Compile OpenSSL 1.0.2 and HAProxy from the source on CentOS 7
# Compile and install HAProxy
rm -rf /tmp/haproxy-current
git clone http://git.haproxy.org/git/haproxy-2.0.git /tmp/haproxy-current
cd /tmp/haproxy-current
make \
TARGET=linux-glibc USE_LINUX_TPROXY=1 USE_ZLIB=1 USE_REGPARM=1 USE_PCRE=1 USE_PCRE_JIT=1 \
USE_OPENSSL=1 SSL_INC=/usr/include SSL_LIB=/usr/lib ADDLIB=-lpthread USE_SYSTEMD=1
make install
# cp /tmp/haproxy-current/examples/haproxy.init /etc/init.d/haproxy
# cp contrib/systemd/haproxy.service.in /etc/systemd/system/haproxy.service
systemctl daemon-reload
if [ $(getent passwd haproxy) ] ; then
echo user haproxy exists
else
echo user haproxy doesn\'t exists, creating
adduser haproxy
gpasswd -a haproxy haproxy
fi
mkdir /etc/haproxy
mkdir /var/lib/haproxy
cp /usr/local/sbin/haproxy /usr/sbin/haproxy20_25
rm -rf /usr/local/sbin/haproxy
rm -rf /tmp/haproxy-current
git clone http://git.haproxy.org/git/haproxy-2.1.git /tmp/haproxy-current
cd /tmp/haproxy-current
make \
TARGET=linux-glibc USE_LINUX_TPROXY=1 USE_ZLIB=1 USE_REGPARM=1 USE_PCRE=1 USE_PCRE_JIT=1 \
USE_OPENSSL=1 SSL_INC=/usr/include SSL_LIB=/usr/lib ADDLIB=-lpthread USE_SYSTEMD=1 \
CFLAGS="-O2 -g -fno-strict-aliasing -DTCP_USER_TIMEOUT=18"
make install
# cp /tmp/haproxy-current/examples/haproxy.init /etc/init.d/haproxy
# cp contrib/systemd/haproxy.service.in /etc/systemd/system/haproxy.service
systemctl daemon-reload
if [ $(getent passwd haproxy) ] ; then
echo user haproxy exists
else
echo user haproxy doesn\'t exists, creating
adduser haproxy
gpasswd -a haproxy haproxy
fi
mkdir /etc/haproxy
mkdir /var/lib/haproxy
cp /usr/local/sbin/haproxy /usr/sbin/haproxy21
rm -rf /usr/local/sbin/haproxy
haproxy21 -vv
rm -rf /tmp/haproxy-current
git clone http://git.haproxy.org/git/haproxy-2.2.git /tmp/haproxy-current
cd /tmp/haproxy-current
make \
TARGET=linux-glibc USE_LINUX_TPROXY=1 USE_ZLIB=1 USE_REGPARM=1 USE_PCRE=1 USE_PCRE_JIT=1 \
USE_OPENSSL=1 SSL_INC=/usr/include SSL_LIB=/usr/lib ADDLIB=-lpthread USE_SYSTEMD=1
make install
# cp /tmp/haproxy-current/examples/haproxy.init /etc/init.d/haproxy
# cp contrib/systemd/haproxy.service.in /etc/systemd/system/haproxy.service
systemctl daemon-reload
if [ $(getent passwd haproxy) ] ; then
echo user haproxy exists
else
echo user haproxy doesn\'t exists, creating
adduser haproxy
gpasswd -a haproxy haproxy
fi
mkdir /etc/haproxy
mkdir /var/lib/haproxy
cp /usr/local/sbin/haproxy /usr/sbin/haproxy22
rm -rf /usr/local/sbin/haproxy
haproxy21 -vv
# Compile and install HAProxy
rm -rf /tmp/haproxy-current
git clone http://git.haproxy.org/git/haproxy-1.9.git /tmp/haproxy-current
cd /tmp/haproxy-current
make \
TARGET=linux2628 USE_LINUX_TPROXY=1 USE_ZLIB=1 USE_REGPARM=1 USE_PCRE=1 USE_PCRE_JIT=1 \
USE_OPENSSL=1 SSL_INC=/usr/include SSL_LIB=/usr/lib ADDLIB=-ldl USE_SYSTEMD=1 \
CFLAGS="-O2 -g -fno-strict-aliasing -DTCP_USER_TIMEOUT=18"
make install
# cp /tmp/haproxy-current/examples/haproxy.init /etc/init.d/haproxy
cp contrib/systemd/haproxy.service.in /etc/systemd/system/haproxy.service
systemctl daemon-reload
if [ $(getent passwd haproxy) ] ; then
echo user haproxy exists
else
echo user haproxy doesn\'t exists, creating
adduser haproxy
gpasswd -a haproxy haproxy
fi
mkdir /etc/haproxy
mkdir /var/lib/haproxy
cp /usr/local/sbin/haproxy /usr/sbin/
systemctl stop haproxy && cp /usr/local/sbin/haproxy /usr/sbin/ && systemctl start haproxy
# make sure you have these installed
yum install -y make gcc perl pcre-devel zlib-devel systemd-devel
# Compile and install OpenSSL - via https://github.com/haproxy/haproxy/blob/master/README
wget -O /tmp/openssl.tgz https://www.openssl.org/source/openssl-1.1.1-latest.tar.gz
tar -zxf /tmp/openssl.tgz -C /tmp
cd /tmp/openssl-*
./config --prefix=/usr --openssldir=/etc/ssl --libdir=lib no-shared zlib-dynamic
make ADDLIB=-lpthread
make install_sw
# Compile and install HAProxy
rm -rf /tmp/haproxy-current
git clone http://git.haproxy.org/git/haproxy-2.1.git /tmp/haproxy-current
cd /tmp/haproxy-current
make \
TARGET=linux-glibc USE_LINUX_TPROXY=1 USE_ZLIB=1 USE_REGPARM=1 USE_PCRE=1 USE_PCRE_JIT=1 \
USE_OPENSSL=1 SSL_INC=/usr/include SSL_LIB=/usr/lib ADDLIB=-lpthread USE_SYSTEMD=1 \
CFLAGS="-O2 -g -fno-strict-aliasing -DTCP_USER_TIMEOUT=18"
make install
# cp /tmp/haproxy-current/examples/haproxy.init /etc/init.d/haproxy
cp contrib/systemd/haproxy.service.in /etc/systemd/system/haproxy.service
systemctl daemon-reload
if [ $(getent passwd haproxy) ] ; then
echo user haproxy exists
else
echo user haproxy doesn\'t exists, creating
adduser haproxy
gpasswd -a haproxy haproxy
fi
mkdir /etc/haproxy
mkdir /var/lib/haproxy
cp /usr/local/sbin/haproxy /usr/sbin/
systemctl stop haproxy && cp /usr/local/sbin/haproxy /usr/sbin/ && systemctl start haproxy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment