Skip to content

Instantly share code, notes, and snippets.

@simkimsia
Last active August 29, 2015 14:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simkimsia/0fe0a5eb9c7504ead53c to your computer and use it in GitHub Desktop.
Save simkimsia/0fe0a5eb9c7504ead53c to your computer and use it in GitHub Desktop.
preparing a fresh 14.04 ubuntu for rails 4
#!/bin/bash
###
#
# forked from https://gist.github.com/1264701/08f93534ba177f173b9382b53c419cd0de5b07ea
#
# Ubuntu 14.04 based web server installation script
# Run this by executing the following from a fresh install of Ubuntu 14.04 server:
#
# bash -c "$(curl -fsSL https://gist.githubusercontent.com/simkimsia/0fe0a5eb9c7504ead53c/raw/58438c9a7c132be94fe5d6687b6f9623968b927f/ubuntu14.04-rails4.sh)" <mysqlPassword>
#
# Be sure to replace <mysqlPassword> with your intended MySQL Password.
# Also, run this as root, unless you enjoy failing.
#
# Its handy to install 'screen' if you want to ensure your remote connection to
# a server doesn't disrupt the installation process. If you want to do this, just
# do the following before running the main bash command:
#
# apt-get install screen -y
# screen
#
# To recover your session if you are disconnected, ssh to your server as root again,
# and type:
#
# screen -x
#
# Dependencies:
# - curl
#
# Todo:
# - SSL Configuration
#
###
EXPECTEDARGS=0
if [ $# -ne $EXPECTEDARGS -o "x$0" == "x" -o $0 == "bash" ]; then
echo "Usage:"
echo " Parameter 1: MySQL root password"
exit 1
fi
MYSQLPASS=$0
export DEBIAN_FRONTEND=noninteractive
########################################
## System Updates
########################################
apt-get update -y
apt-get install \
curl \
aptitude \
-y
apt-get upgrade --force-yes -y
########################################
## Tools and Utilities
########################################
apt-get install git-core --force-yes -y
apt-get install xclip --force-yes -y
########################################
## MySQL
########################################
apt-get install \
mysql-client \
mysql-server \
--force-yes -y
mysqladmin -u root password $MYSQLPASS
########################################
## Remove any unwanted packages
########################################
apt-get autoremove --force-yes -y
########################################
## Using RVM to install rails 4.1 http://railsapps.github.io/installrubyonrails-ubuntu.html
########################################
########################################
## Install RVM first
## Note the backslash before “curl” (this avoids potential version conflicts).
## The "—ruby" flag will install the newest version of Ruby.
########################################
\curl -L https://get.rvm.io | bash -s stable --ruby
########################################
## To start using RVM you need to run `source /usr/local/rvm/scripts/rvm`
## in all your open shell windows, in rare cases you need to reopen all shell windows.
########################################
source /usr/local/rvm/scripts/rvm
########################################
## Since Rails 3.1, a JavaScript runtime has been needed for development on Ubuntu Linux.
## The JavaScript runtime is required to compile code for the Rails asset pipeline.
########################################
apt-get install nodejs --force-yes -y
########################################
## If you install Rails at this point, you will install it into the global gemset.
## Instead, make a gemset just for the current stable release:
########################################
rvm use ruby-2.1.1@rails4.1 --create
gem install rails
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment