Skip to content

Instantly share code, notes, and snippets.

@ismailakbudak
Last active August 29, 2015 14:19
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 ismailakbudak/89923b7d8138c50ecaef to your computer and use it in GitHub Desktop.
Save ismailakbudak/89923b7d8138c50ecaef to your computer and use it in GitHub Desktop.
Ubuntu install ruby on rails environment
#!/bin/bash
## Exit trap
trap 'ret=$?; test $ret -ne 0 && printf "failed\n\n" >&2; exit $ret' EXIT
set -e
## Fancy echo
fancy_echo() {
printf "\n%b\n" "$1"
}
## Debian-Ubuntu package update
fancy_echo "Updating system packages ..."
sudo apt-get update
## Extra components
fancy_echo "Installing ImageMagick, to crop and resize images ..."
sudo apt-get install -y imagemagick
fancy_echo "Installing libraries for common gem dependencies ..."
sudo apt-get install libxslt1-dev libcurl4-openssl-dev libksba8 libksba-dev libqtwebkit-dev libreadline-dev libpq-dev
fancy_echo "Installing watch, to execute a program periodically and show the output ..."
sudo apt-get install watch
fancy_echo "Installing NodeJS, a Javascript runtime ..."
sudo apt-get install nodejs
## Rbenv
if [[ ! -d "$HOME/.rbenv" ]]; then
fancy_echo "Installing rbenv, to change Ruby versions ..."
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
if ! grep -qs "rbenv init" ~/.zshrc; then
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
fi
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
fi
if [[ ! -d "$HOME/.rbenv/plugins/rbenv-gem-rehash" ]]; then
fancy_echo "Installing rbenv-gem-rehash so the shell automatically picks up binaries after installing gems with binaries..."
git clone https://github.com/sstephenson/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash
fi
if [[ ! -d "$HOME/.rbenv/plugins/ruby-build" ]]; then
fancy_echo "Installing ruby-build, to install Rubies ..."
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
fi
## Ruby dependencies
fancy_echo "Installing Ruby dependencies ..."
sudo apt-get install zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev
## Ruby environment
RUBY_VERSION="2.1.2"
fancy_echo "Preveting gem system from installing documentation ..."
echo 'gem: --no-ri --no-doc' >> ~/.gemrc
fancy_echo "Installing Ruby $RUBY_VERSION ..."
rbenv install $RUBY_VERSION
fancy_echo "Setting $RUBY_VERSION as global default Ruby ..."
rbenv global $RUBY_VERSION
rbenv rehash
fancy_echo "Updating to latest Rubygems version ..."
gem update --system
fancy_echo "Installing Rails ..."
gem install rails
fancy_echo "Installing PostgreSQL Ruby interface ..."
gem install pg
@ismailakbudak
Copy link
Author

Run on terminal:
bash <(curl -s https://gist.githubusercontent.com/ismailakbudak/89923b7d8138c50ecaef/raw/ad2e0ba49ef9f0203a14b127b943cdb3c2e1700e/ubuntu-rails.sh)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment