Created
November 18, 2013 23:08
-
-
Save regisnew/7537039 to your computer and use it in GitHub Desktop.
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 12.04" | |
echo "Read more: https://github.com/nrk/predis" | |
echo "Author: Ralf Rottmann | @ralf | http://rottmann.net" | |
echo "--------------------------------------------------------------------------------------------" | |
PHP5_CONF_DIR="/etc/php5/conf.d" | |
PHP_INCLUDE_DIR="/usr/share/php5" | |
echo "Checking prerequisites..." | |
echo "Git available?" | |
[ ! -s /usr/bin/git ] && sudo apt-get -q -y install git || echo "Git already installed." | |
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 php5-dev..." | |
sudo apt-get -q -y install php5-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" | |
cp phpiredis.* $acc_php_extension_dir | |
echo "Step 2.2: Adding phpiredis.ini to $PHP5_CONF_DIR..." | |
[ -s $PHP5_CONF_DIR/phpiredis.ini ] && echo "phpiredis.ini already exists" || echo extension=phpiredis.so >> $PHP5_CONF_DIR/phpiredis.ini | |
echo "--------------------------------------------------------------------------------------------" | |
echo "Step 2.3: Restarting Apache 2..." | |
apache2ctl restart | |
echo "Done." | |
} | |
echo "--------------------------------------------------------------------------------------------" | |
echo "Step 3: Installing Flexible and feature-complete PHP client library for Redis predis from http://wiki.github.com/nrk/predis" | |
cd | |
[ -s predis ] && { | |
echo Removing folder predis | |
rm -rf predis | |
} | |
git clone https://github.com/nrk/predis.git | |
echo "Step 3.1: Moving to /usr/share/php" | |
[ -s $PHP_INCLUDE_DIR/Predis ] && { | |
echo "$PHP_INCLUDE_DIR/Predis already exists, removing..." | |
rm -rf $PHP_INCLUDE_DIR/Predis | |
} | |
echo "Moving newly created to $PHP_INCLUDE_DIR/Predis..." | |
[ ! -s $PHP_INCLUDE_DIR ] && { | |
echo "Include directory does not exist. Creating it." | |
mkdir $PHP_INCLUDE_DIR | |
} | |
mv predis/lib/Predis $PHP_INCLUDE_DIR/Predis | |
echo "--------------------------------------------------------------------------------------------" | |
echo "Finished." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment