Skip to content

Instantly share code, notes, and snippets.

@iJackUA
Created October 25, 2013 13:17
Show Gist options
  • Save iJackUA/7154546 to your computer and use it in GitHub Desktop.
Save iJackUA/7154546 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ "$(whoami)" != "root" ]; then
echo "ERROR : Run script as Root (sudo !!) please"
exit 1
fi
read -e -p "php_mongo version to be installed (change if needed) : " -i "1.4.4" VERSION
echo 'Installing php_mongo v.'$VERSION' ... '
# installing build essentials if it is missing
apt-get install php5-dev php-pear
wget https://github.com/mongodb/mongo-php-driver/archive/$VERSION.tar.gz
tar xzf $VERSION.tar.gz
cd mongo-php-driver-$VERSION
phpize
./configure
make
make install
cd ..
rm mongo-php-driver-$VERSION -R
rm $VERSION.tar.gz
mv /etc/php5/mods-available/mongo.ini /etc/php5/mods-available/mongo.bkp
touch /etc/php5/mods-available/mongo.ini
echo "extension=mongo.so" > /etc/php5/mods-available/mongo.ini
ln -s /etc/php5/mods-available/mongo.ini /etc/php5/apache2/conf.d/mongo.ini
ln -s /etc/php5/mods-available/mongo.ini /etc/php5/cli/conf.d/mongo.ini
service apache2 restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment