Skip to content

Instantly share code, notes, and snippets.

@changeme
Created September 14, 2017 10:09
Show Gist options
  • Save changeme/3a36832da91aa434c06cb4590f734d01 to your computer and use it in GitHub Desktop.
Save changeme/3a36832da91aa434c06cb4590f734d01 to your computer and use it in GitHub Desktop.
Redis installer for cPanel
#!/bin/bash
# Tested on: CENTOS 7.3 lxc v66.0.19
# Source: https://help.bigscoots.com/cpanel/cpanel-easyapache-4-installing-redis-and-redis-php-extension
VERSION=`rpm -q --queryformat '%{VERSION}' centos-release`
yum install -y -q remi-release epel-release
yum update
yum -y -q install redis --enablerepo=remi --disableplugin=priorities
if [ $VERSION = 6 ] ; then
chkconfig redis on && service redis start
fi
if [ $VERSION = 7 ] ; then
systemctl enable redis && systemctl start redis
fi
for phpver in $(ls -1 /opt/cpanel/ |grep ea-php | sed 's/ea-php//g') ; do
cd ~
wget -nv -c -O redis.tgz https://pecl.php.net/get/redis
tar -xvf redis.tgz
cd ~/redis* || exit
/opt/cpanel/ea-php"$phpver"/root/usr/bin/phpize
./configure --with-php-config=/opt/cpanel/ea-php"$phpver"/root/usr/bin/php-config
make && make install
echo 'extension=redis.so' > /opt/cpanel/ea-php"$phpver"/root/etc/php.d/redis.ini
rm -rf ~/redis*
done
/scripts/restartsrv_httpd
/scripts/restartsrv_apache_php_fpm
for phpver in $(ls -1 /opt/cpanel/ |grep php | sed 's/ea-php//g') ; do
echo "PHP $phpver" ; /opt/cpanel/ea-php$phpver/root/usr/bin/php -i |grep "Redis Support"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment