Skip to content

Instantly share code, notes, and snippets.

@pietrop
Last active October 5, 2015 21:09
Show Gist options
  • Save pietrop/b6a6d62d2af23d1f6225 to your computer and use it in GitHub Desktop.
Save pietrop/b6a6d62d2af23d1f6225 to your computer and use it in GitHub Desktop.
## a script to config ubuntu EC2 instance with quickQuote. http://times.github.io/quickQuote/
## run the script form terminal in the ec2 instance using:
## ./config_ec2.sh
## you might need to adjust permissions to run it using:
## sudo chmod 600 ./config_ec2.sh
## http://dennissuratna.com/rails-deployment-aws1/
## http://dennissuratna.com/rails-deployment-aws2/
## http://dennissuratna.com/rails-deployment-aws3/
## Installs on the EC2 instance:
## ruby-2.0.0-p353
## Rails 4.0.1
## Git
## rails Passenger gem
## ffmpeg
## and you'll also need MySQL RDS for db,
## add these two gems to rails gem file.
## gem passenger
## gem mysql2
## Installing essential packages
sudo apt-get update
sudo apt-get install build-essential libopenssl-ruby1.9.1 libssl-dev zlib1g-dev libmysqlclient-dev libpcre3-dev libcurl4-openssl-dev mysql-client-core-5.5 openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison nodejs subversion
################ Istalling ruby
## Install rbenv
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.profile
echo 'eval "$(rbenv init -)"' >> ~/.profile
## Install ruby-build
cd ~
git clone https://github.com/sstephenson/ruby-build.git
cd ruby-build
sudo ./install.sh
## Restart Shell
cd ~
exec $SHELL -l
## Install Ruby and Bundler
rbenv install 2.0.0-p353
rbenv global 2.0.0-p353
gem install bundler
################ Generating SSH key and add it to Bitbucket/Github
## If you created your app repository as private on Bitbucket/Github, you would not be able to clone it inside your Ubuntu instance unless you add the SSH key of your instance to your Github/Bitbucket profile. If your repository is public, you can skip this step entirely.
## Create an SSH key by running the following command
# ssh-keygen
## Your new SSH key should be in ~/.ssh/id_rsa.pub. Copy the content of that file and add it to your list of SSH keys in Github/Bitbucket.
################ Cloning your app and starting the server
## Once you have added your SSH key, clone your repository to your home directory (Note: real-world scenarios often use /var/apps to store its application codes) and install all of the necessary gems
cd ~
## change this line to the repository you are going to clone, use https if you don't want to have to worry about ssh keys.
# git clone git@bitbucket.org:denniss/blogapp.git
git clone https://github.com/times/quickQuote.git
# cd ./blogapp
cd ./quickQuote
rbenv rehash
bundle install
rbenv rehash
################ start the app
## Once you have installed all the gem dependencies, you are ready to start your app
rbenv sudo passenger start -p80 &
## Once Passenger is and started, you can see your app by entering the Public DNS to your browser.
################ Database
## if updating app after adding db, uncomment following lines.
# git pull origin master
# bundle install
# rbenv rehash
## initialise RDS MySQL db
rake db:migrate RAILS_ENV=production
## Assets precompile
rbenv sudo rake assets:precompile RAILS_ENV=production
################ Install ffmpeg
# install linux brew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/linuxbrew/go/install)"
# install ffmpeg using brew
brew install ffmpeg --enable-gpl --enable-version3 --enable-avresample --enable-libx264 -- nable-libmp3lame -- nable-libvo-aacenc --enable-libxvid --enable-libvorbis --enable-libvpx
################ restart the Passenger server into production
rbenv sudo passenger stop -p80
rbenv sudo passenger start -p80 -d -e production
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment