-
-
Save vmosoti/f7d3f7d7506554facdbf5fb848b9e121 to your computer and use it in GitHub Desktop.
Installing Redis, Hiredis on Ubuntu 14.04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "--------------------------------------------------------------------------------------------" | |
echo "Installing Predis on Ubuntu 16.04" | |
echo "Read more: https://github.com/nrk/predis" | |
echo "Author: Ralf Rottmann | @ralf | http://rottmann.net" | |
echo "--------------------------------------------------------------------------------------------" | |
PHP_CONF_DIR="/etc/php/7.0/apache2/conf.d" | |
echo "Checking prerequisites..." | |
echo "Git available?" | |
[ ! -s /usr/bin/git ] && sudo apt-get -q -y install git || echo "Git already installed." | |
echo "--------------------------------------------------------------------------------------------" | |
echo "Step 0: Installing a PHP extension for Redis from https://github.com/phpredis/phpredis" | |
cd | |
found=$(find / -name "redis.so" 2> /dev/null) | |
[[ -n $found ]] && { | |
echo "Library already installed." | |
} || | |
{ | |
git clone http://github.com/phpredis/phpredis | |
cd phpredis | |
found=$(which phpize) | |
[[ ! -n $found ]] && { | |
echo "Missing phpize. Installing php7.0-dev..." | |
sudo apt-get -q -y install php7.0-dev | |
} | |
phpize | |
./configure | |
make && make install | |
echo "extension=redis.so" > /etc/php/7.0/mods-available/redis.ini | |
sudo ln -sf /etc/php/7.0/mods-available/redis.ini /etc/php/7.0/apache2/conf.d/20-redis.ini | |
sudo ln -sf /etc/php/7.0/mods-available/redis.ini /etc/php/7.0/cli/conf.d/20-redis.ini | |
sudo service apache2l restart | |
echo "Done installing a PHP extension for Redis!" | |
} | |
echo "--------------------------------------------------------------------------------------------" | |
echo "Step 1: Installing the Minimalistic C client for Redis >= 1.2 from https://github.com/redis/hiredis" | |
cd | |
found=$(find / -name "libhiredis.so" 2> /dev/null) | |
[[ -n $found ]] && { | |
echo "Library already installed." | |
} || | |
{ | |
git clone http://github.com/redis/hiredis | |
cd hiredis | |
make && make install | |
ldconfig | |
echo "Done." | |
} | |
echo "--------------------------------------------------------------------------------------------" | |
echo "Step 2: Installing PHP bindings for Hiredis Redis client from https://github.com/nrk/phpiredis" | |
found=$(find / -name "phpiredis.so" 2> /dev/null) | |
[[ -n $found ]] && { | |
echo "phpiredis.so already exists. Please make sure it gets loaded in your php.ini." | |
} || | |
{ | |
cd | |
[ -s phpiredis ] && { | |
echo Removing folder phpiredis | |
rm -rf phpiredis | |
} | |
git clone https://github.com/nrk/phpiredis.git | |
cd phpiredis | |
found=$(which phpize) | |
[[ ! -n $found ]] && { | |
echo "Missing phpize. Installing php7.0-dev..." | |
sudo apt-get -q -y install php7.0-dev | |
} | |
phpize | |
./configure --enable-phpiredis --with-hiredis-dir=/usr/local | |
make | |
cd modules | |
acc_php_extension_dir=$(php-config --extension-dir) | |
echo "--------------------------------------------------------------------------------------------" | |
echo "Step 2.1: Copying to PHP extension directory $acc_php_extension_dir" | |
sudo cp phpiredis.* $acc_php_extension_dir | |
echo "Step 2.2: Adding phpiredis.ini to $PHP_CONF_DIR..." | |
[ -s $PHP_CONF_DIR/phpiredis.ini ] && echo "phpiredis.ini already exists" || echo extension=phpiredis.so >> $PHP_CONF_DIR/phpiredis.ini | |
echo "--------------------------------------------------------------------------------------------" | |
echo "Step 2.3: Restarting Apache 2..." | |
apache2ctl restart | |
echo "Done installing Hiredis Redis client!" | |
} | |
echo "Finished." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment