Statically compile redis 3.0.2 on CentOS 5 (RHEL 5)

How to statically compile redis 3.0.2 on CentOS 5 (RHEL 5)


Install tcl8.5

tar xfz tcl8.5.18-src.tar.gz
cd tcl8.5.18/unix
make test
make install

Compile redis

Statically linked binaries

make CFLAGS="-static" EXEEXT="-static" LDFLAGS="-I/usr/local/include/"

Dynamically linked binaries

make LDFLAGS="-I/usr/local/include/"

How to manually install redis

cd src/
cp redis-{server,cli} /usr/local/bin/
chown root: /usr/local/bin/redis-{server,cli}
chmod 755 /usr/local/bin/redis-{server,cli}
mkdir /{var,etc}/redis /var/redis/6379
chmod 775 /{var,etc}/redis
cp redis.conf /etc/redis/6379.conf
sed -i 's/daemonize no/daemonize yes/' /etc/redis/6379.conf
sed -i 's,pidfile /var/run/,pidfile /var/run/,' /etc/redis/6379.conf
sed -i 's/^# bind' /etc/redis/6379.conf
sed -i 's,logfile "",logfile "/var/log/redis_6379.log",' /etc/redis/6379.conf
sed -i 's,dir ./,dir /var/redis/6379,' /etc/redis/6379.conf