Created
January 25, 2012 20:11
-
-
Save FrancisVarga/1678383 to your computer and use it in GitHub Desktop.
setup development environment, taken from https://gist.github.com/987713
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 | |
# Purpose: Just run this script to install the required | |
# ubuntu/pear packages for php development. | |
# | |
# Tested on Ubuntu 11.xx | |
# ---------------------------------------------------------- | |
#### DEFINITIONS ### | |
IPADDR=$(ip addr | grep inet | grep brd | cut -c10-22 | cut -d\/ -f1) | |
CB_RELEASE=http://files.couchbase.com/developer-previews/couchbase-server-2.0.0-dev-preview/couchbase-server-community_x86_64_2.0.0-dev-preview-3.deb | |
OS=NULL | |
MIN_OS=ubuntu | |
ARCH=NULL | |
VERSION=NULL | |
MIN_VERSION=11.07 | |
DISTNAME=NULL | |
JAVA_TARFILE=jdk-7-linux-x64.tar.gz | |
JAVA_TEMP_DIR=jdk1.7.0 | |
JAVA_HOME=/opt/sun/jdk-7-linux-x64 | |
#### FUNCTIONS #### | |
export_distribution () | |
{ | |
OS=$(awk '/DISTRIB_ID=/' /etc/*-release | sed 's/DISTRIB_ID=//' | tr '[:upper:]' '[:lower:]') | |
DISTNAME=$(awk '/DISTRIB_CODENAME=/' /etc/*-release | sed 's/DISTRIB_CODENAME=//' | tr '[:upper:]' '[:lower:]') | |
ARCH=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/') | |
VERSION=$(awk '/DISTRIB_RELEASE=/' /etc/*-release | sed 's/DISTRIB_RELEASE=//' | sed 's/[.]0/./') | |
if [ -z "$OS" ]; then | |
OS=$(awk '{print $1}' /etc/*-release | tr '[:upper:]' '[:lower:]') | |
fi | |
if [ -z "$VERSION" ]; then | |
VERSION=$(awk '{print $3}' /etc/*-release) | |
fi | |
} | |
verify_distribution () | |
{ | |
echo "" | |
echo "verifying minimum system requirements ..." | |
echo "" | |
if [ $OS != $MIN_OS ]; then | |
echo "This script will not runder under any other distribution than $MIN_OS." | |
exit | |
else | |
echo "as 64 Bit OS detected." | |
fi | |
if [ $(echo $VERSION | sed 's/\.//') -lt $(echo $MIN_VERSION | sed 's/\.//') ]; then | |
echo "Your Distribution $VERSION is NOT >= $MIN_VERSION" | |
exit | |
else | |
echo "OS detected is: $OS $DISTNAME $VERSION" | |
fi | |
if [ $ARCH != 64 ]; then | |
echo -n "No 64 Bit OS Detected... sure to continue? (Press ENTER to continue, CTRL-c to cancel) " | |
read DUMMY | |
echo "" | |
else | |
echo "as 64 Bit OS detected." | |
fi | |
echo "---- your OS looks fine. ---" | |
echo "" | |
} | |
install_java () | |
{ | |
if [ $ARCH != 64 ]; then return; fi; | |
if [ -f $JAVA_TARFILE ]; then | |
echo "found $JAVA_TARFILE" | |
tar xzf $JAVA_TARFILE | |
if [ -d $JAVA_TEMP_DIR ]; then | |
sudo mkdir -v -p $JAVA_HOME && sudo mv -v $JAVA_TEMP_DIR/* $JAVA_HOME | |
fi | |
if [ -d $JAVA_HOME ]; then | |
echo 'PATH="'$JAVA_HOME'/bin:$PATH"' > /tmp/jdk.sh | |
echo "export JAVA_HOME=$JAVA_HOME" >> /tmp/jdk.sh | |
sudo mv -v /tmp/jdk.sh /etc/profile.d/jdk.sh | |
echo "--------------------------------" | |
echo "success! JDK is installed." | |
echo "--------------------------------" | |
echo "" | |
else | |
echo "--------------------------------" | |
echo "FAIL! JDK install did not succeed..." | |
echo "You have to install the JDK later manually..." | |
echo "--------------------------------" | |
echo "" | |
fi | |
else | |
echo "--------------------------------" | |
echo "FAIL! '$JAVA_TARFILE' NOT found!" | |
echo "You have to install the JDK later manually..." | |
echo "--------------------------------" | |
echo "" | |
fi | |
if [ -f /tmp/jdk.sh ]; then rm -f /tmp/jdk.sh; fi | |
if [ -d $JAVA_TEMP_DIR ]; then rm -r -f $JAVA_TEMP_DIR; fi | |
} | |
install_memcached () | |
{ | |
sudo pecl install igbinary | |
echo "extension=igbinary.so" > /tmp/igbinary.ini | |
sudo mv -v /tmp/igbinary.ini /etc/php5/conf.d/igbinary.ini | |
wget http://launchpad.net/libmemcached/1.0/1.0.3/+download/libmemcached-1.0.3.tar.gz && tar xzvf libmemcached-1.0.3.tar.gz | |
pushd . | |
if [ -d ./libmemcached-1.0.3 ]; then | |
cd libmemcached-1.0.3 | |
./configure --prefix=/usr | |
make test && sudo make install | |
fi | |
popd | |
if [ -d ./libmemcached-1.0.3 ]; then | |
rm -r -f libmemcached-1.0.3 | |
rm -f libmemcached-1.0.3.tar.gz | |
fi | |
wget http://pecl.php.net/get/memcached-2.0.0b2.tgz && tar xzf memcached-2.0.0b2.tgz | |
pushd . | |
if [ -d ./memcached-2.0.0b2 ]; then | |
cd memcached-2.0.0b2 | |
phpize | |
./configure --enable-memcached-igbinary --enable-memcached-json | |
make test && sudo make install | |
sudo updatedb | |
MEMCACHED_SO=`locate memcached.so | tail -1` | |
if [ -f $MEMCACHED_SO ]; then | |
echo "extension=$MEMCACHED_SO" > /tmp/memcached.ini | |
sudo mv -v /tmp/memcached.ini /etc/php5/conf.d/memcached.ini | |
fi | |
fi | |
popd | |
if [ -d ./memcached-2.0.0b2 ]; then | |
rm -r -f memcached-2.0.0b2 | |
rm -f memcached-2.0.0b2.tgz | |
fi | |
} | |
configure_xcache () | |
{ | |
sudo updatedb | |
XCACHE_SO=`locate xcache.so | tail -1` | |
echo '[xcache-common]' > /tmp/xcache.ini | |
echo "zend_extension = $XCACHE_SO" >> /tmp/xcache.ini | |
echo '[xcache.admin]' >> /tmp/xcache.ini | |
echo '; Change xcache.admin.user to your preferred login name ' >> /tmp/xcache.ini | |
echo 'xcache.admin.user = "admin"' >> /tmp/xcache.ini | |
echo '; Change xcache.admin.pass to the MD5 fingerprint of your password' >> /tmp/xcache.ini | |
echo '; Use md5 -s "your_secret_password" to find the fingerprint' >> /tmp/xcache.ini | |
echo 'xcache.admin.pass = "b6273b589df2dfdbd8fe35b1011e3183"' >> /tmp/xcache.ini | |
echo '[xcache]' >> /tmp/xcache.ini | |
echo '; Change xcache.size to tune the size of the opcode cache' >> /tmp/xcache.ini | |
echo 'xcache.size = 64M' >> /tmp/xcache.ini | |
echo 'xcache.shm_scheme = "mmap"' >> /tmp/xcache.ini | |
echo 'xcache.count = 2' >> /tmp/xcache.ini | |
echo 'xcache.slots = 8K' >> /tmp/xcache.ini | |
echo 'xcache.ttl = 0' >> /tmp/xcache.ini | |
echo 'xcache.gc_interval = 0' >> /tmp/xcache.ini | |
echo '; Change xcache.var_size to adjust the size of variable cache' >> /tmp/xcache.ini | |
echo 'xcache.var_size = 8M' >> /tmp/xcache.ini | |
echo 'xcache.var_count = 1' >> /tmp/xcache.ini | |
echo 'xcache.var_slots = 8K' >> /tmp/xcache.ini | |
echo 'xcache.var_ttl = 0' >> /tmp/xcache.ini | |
echo 'xcache.var_maxttl = 0' >> /tmp/xcache.ini | |
echo 'xcache.var_gc_interval = 300' >> /tmp/xcache.ini | |
echo 'xcache.test = Off' >> /tmp/xcache.ini | |
echo 'xcache.readonly_protection = On' >> /tmp/xcache.ini | |
echo 'xcache.mmap_path = "/tmp/xcache"' >> /tmp/xcache.ini | |
echo 'xcache.coredump_directory = ""' >> /tmp/xcache.ini | |
echo 'xcache.cacher = On' >> /tmp/xcache.ini | |
echo 'xcache.stat = On' >> /tmp/xcache.ini | |
echo 'xcache.optimizer = Off' >> /tmp/xcache.ini | |
echo '[xcache.coverager]' >> /tmp/xcache.ini | |
echo 'xcache.coverager = On' >> /tmp/xcache.ini | |
echo 'xcache.coveragedump_directory = ""' >> /tmp/xcache.ini | |
sudo mv -v /tmp/xcache.ini /etc/php5/conf.d/xcache.ini | |
} | |
#### RUNTIME #### | |
clear | |
export_distribution | |
verify_distribution | |
echo "Installing basic packages for development." | |
echo "Notes:" | |
echo "- if asked for a password, provide your system user password" | |
echo "- if asked for a mysql server password, enter 'root'" | |
echo -n "Press ENTER to continue, CTRL-c to cancel:" | |
read DUMMY | |
sudo echo | |
sudo apt-get update | |
# Basic Server Setup | |
sudo apt-get --assume-yes install \ | |
apache2 \ | |
apache2-utils \ | |
mysql-server \ | |
mysql-client \ | |
mysqltuner \ | |
beanstalkd \ | |
libmemcached-dev | |
# activate beanstalkd: | |
sudo echo "START=yes" >> /etc/default/beanstalkd | |
sudo service beanstalkd restart | |
# JDK Setup | |
install_java | |
# PHP & build tools | |
sudo apt-get --assume-yes install \ | |
libssl0.9.8 \ | |
libssl1.0.0 \ | |
libssl-dev \ | |
build-essential \ | |
autoconf \ | |
libcloog-ppl0 \ | |
libcloog-ppl1 \ | |
libcloog-ppl-dev | |
sudo apt-get --assume-yes install \ | |
libapache2-mod-php5 \ | |
php5-dev \ | |
php-pear \ | |
php5-mysql \ | |
php5-xdebug \ | |
php5-xcache \ | |
php5-suhosin \ | |
php5-gd \ | |
php5-mcrypt \ | |
php5-xsl \ | |
php5-curl \ | |
php5-imagick | |
configure_xcache | |
# update php memory limit | |
echo "Raising memory limit in php.ini files" | |
sudo sed -i -r 's/^ *memory_limit *= *.*/memory_limit = 32M/' /etc/php5/apache2/php.ini | |
sudo sed -i -r 's/^ *memory_limit *= *.*/memory_limit = 32M/' /etc/php5/cli/php.ini | |
# development environment & other tools: | |
echo "Setup developer tools" | |
sudo apt-get --assume-yes install \ | |
flip \ | |
git-all \ | |
vim \ | |
gettext \ | |
ssh \ | |
wget \ | |
curl \ | |
nmap \ | |
traceroute \ | |
rsync \ | |
zlib1g-dev | |
# installing memcached stuff: | |
install_memcached | |
# installing couchbase stuff: | |
sudo apt-get --assume-yes install \ | |
libc6 \ | |
libgcc1 \ | |
libncurses5 \ | |
libsasl2-2 \ | |
libssl0.9.8 \ | |
libstdc++6 \ | |
zlib1g \ | |
lsb-base | |
if [ -f couchbase-server.deb ]; then | |
true | |
else | |
wget $CB_RELEASE -O couchbase-server.deb | |
fi | |
if [ -f couchbase-server.deb ]; then | |
sudo dpkg -i couchbase-server.deb && rm -f couchbase-server.deb | |
fi | |
# xDebug stuff: | |
# + enable xdebug profiling trigger: | |
sudo updatedb | |
XDEBUG_SO=`locate xdebug.so|tail -1` | |
echo "zend_extension=$XDEBUG_SO" > /tmp/xdebug.ini | |
echo '[XDebug]' >> /tmp/xdebug.ini | |
echo 'xdebug.remote_enable=1' >> /tmp/xdebug.ini | |
echo 'xdebug.remote_host=localhost' >> /tmp/xdebug.ini | |
echo 'xdebug.remote_port=9000' >> /tmp/xdebug.ini | |
echo 'xdebug.remote_handler="dbgp"' >> /tmp/xdebug.ini | |
echo 'xdebug.profiler_enable_trigger=1' >> /tmp/xdebug.ini | |
echo 'xdebug.collect_params=1' >> /tmp/xdebug.ini | |
echo 'xdebug.coverage_enable=1' >> /tmp/xdebug.ini | |
echo 'xdebug.extended_info=1' >> /tmp/xdebug.ini | |
echo 'xdebug.profiler_output_dir=/tmp/' >> /tmp/xdebug.ini | |
sudo mv -v /tmp/xdebug.ini /etc/php5/conf.d/xdebug.ini | |
# enable Apache extensions: | |
echo "Enabling Apache mod_rewrite & restarting Apache" | |
sudo a2enmod rewrite | |
sudo service apache2 reload | |
echo "" | |
echo "------------------------- DONE!!! Setup finished ----" | |
echo "" | |
echo "" | |
echo "Pls. visit => http://$IPADDR:8091 Couchbase Console" | |
echo "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment