Skip to content

Instantly share code, notes, and snippets.

@markglenfletcher
Created June 25, 2015 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markglenfletcher/88cb9ada15dbb9a77749 to your computer and use it in GitHub Desktop.
Save markglenfletcher/88cb9ada15dbb9a77749 to your computer and use it in GitHub Desktop.
Ubuntu Rbenv/Ruby2.1.6/Nginx/MySQL stack setup script
#!/usr/bin/env bash
set -e
#
# Justin Cases
#
cd $HOME
#
# Update base image
#
apt-get update
apt-get install -y curl git-core build-essential zlib1g-dev libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libcurl4-openssl-dev libxml2-dev libxslt1-dev python-software-properties
#
# Install rbenv
#
if [[ ! -e ~/.rbenv/bin/rbenv ]]; then
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
fi
RUBY_VERSION=2.1.6
#
# Install Ruby
#
if [[ ! -e ~/.rbenv/shims/ruby ]]; then
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
rbenv install $RUBY_VERSION
rbenv global $RUBY_VERSION
fi
#
# Install Bundler
#
if [[ ! -e ~/.rbenv/shims/bundle ]]; then
gem install bundler
fi
apt-get --reinstall install -y bsdutils
#
# Install MySQL
#
if [[ ! -e /usr/bin/mysql ]]; then
debconf-set-selections <<< 'mysql-server mysql-server/root_password password password'
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password password'
apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" git libmysqlclient-dev libxml2-dev mysql-server-5.5
fi
#
# Install nginx
#
if [[ ! -e /usr/sbin/nginx ]]; then
apt-get install -y nginx
service nginx start
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment