Skip to content

Instantly share code, notes, and snippets.

@leebrooks0
Created April 28, 2013 17:24
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 leebrooks0/5477591 to your computer and use it in GitHub Desktop.
Save leebrooks0/5477591 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm
# Before we do anything else, we should run a quick update to make sure that all of the packages we download are up to date:
echo 'Updating system packages...'
sudo apt-get update
# Install RVM to install the latest version of Ruby
echo 'Installing RVM...'
sudo apt-get install curl
echo Y #Installing curl :Do you want to continue...
\curl -L https://get.rvm.io | bash -s stable
reset # Start a new terminal session (apparently needed in rare cases)
source /home/vagrant/.rvm/scripts/rvm
#Install missing required packages.
#sudo apt-get install git-core
#echo Y
# RVM can install all the packages necessary for Ruby/Rails if enabled.
rvm autolibs enable
rvm requirements # This line does the install of the missing requirements
# Install Ruby and set it as the default Ruby
echo 'Installing Ruby...'
rvm install 2.0.0-p0
rvm use 2.0.0-p0 --default
echo 'Ruby -v ' + ruby -v
# Install RubyGems
echo 'Installing RubyGems...'
rvm rubygems current
# Ubuntu does not have a javascript runtime...
echo 'Installing Node.js ...'
sudo apt-get install nodejs
echo Y
# Install and start MySql
#https://www.digitalocean.com/community/articles/how-to-install-rails-apache-and-mysql-on-ubuntu-with-passenger
echo 'Installing MySql.'
sudo apt-get install mysql-server
echo 'Starting MySql...'
sudo service mysql start
# Move into the app's root folder (vagrant ssh launches into /home/vagrant and we need to be in /vagrant)
cd ..
cd ..
cd /vagrant
# Run Bundler to install Rails and all the others gems
echo 'Installing all Gems as per the GemFile...'
# http://stackoverflow.com/questions/4735303/failed-to-install-gem-install-eventmachine-i-need-starling-in-my-project-fo
sudo apt-get install build-essential # Installs compilers needed to compile gems that are native extensions.
echo Y
bundle
# Start Guard
echo 'Starting Guard. Please make sure you have a Growl client installed...'
bundle exec guard
# Run the necessary Rake tasks
echo 'Creating the database...'
rake db:create
echo 'Migrating the database to the latest schema...'
rake db:migrate
# Start the WebBrick WebServer
echo 'Starting the Rails WebBrick development server on port 3000...'
rails server
echo 'Vagrant has finished configuring your development environment!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment