Skip to content

Instantly share code, notes, and snippets.

@lucduong
Created December 2, 2016 03:14
Show Gist options
  • Save lucduong/49e14b448328ba74618206d362b06cb1 to your computer and use it in GitHub Desktop.
Save lucduong/49e14b448328ba74618206d362b06cb1 to your computer and use it in GitHub Desktop.

Create Instance

Create on Amazon EC2

Connect to AMI

ssh -i "nykfuel-luc.pem" ec2-user@ec2-54-222-135-36.cn-north-1.compute.amazonaws.com.cn

Install development tools

yum groupinstall "Development Tools"

yum install git pcre pcre-devel

yum install postgresql94-devel

Install rbenv

git clone git://github.com/sstephenson/rbenv.git /home/deployer/.rbenv

Create the following file:

nano /etc/profile.d/rbenv.sh

Paste below code and then save

export RBENV_ROOT=/usr/local/rbenv
export PATH="${RBENV_ROOT}/bin:$PATH"
eval "$(rbenv init -)"

Install ruby-build

. /etc/profile

git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build

yum install -y openssl-devel readline-devel zlib-devel

rbenv install 2.2.3

It looks like this

Downloading ruby-2.2.3.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.3.tar.bz2
Installing ruby-2.2.3...
Installed ruby-2.2.3 to /usr/local/rbenv/versions/2.2.3

Make this version become global version

rbenv global 2.2.3

rbenv rehash

When you use Amazon Linux (China)

gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/

To check the current source

gem sources -l

*** CURRENT SOURCES ***

https://ruby.taobao.org

Install bundler

gem update --system

gem install bundler

And...

bundle config mirror.https://rubygems.org https://ruby.taobao.org

Install Rails

gem install rails

Install NodeJs

yum install nodejs npm --enablerepo=epel

Access from internet to server

Need to add HTTP Connection. Inbound rule. http tcp 80 0.0.0.0/0

Setup nykfuel-server

RAILS_ENV=staging rake db:create
RAILS_ENV=staging rake db:migrate
RAILS_ENV=staging rake db:seed

RAILS_ENV=staging rake assets:precompile
staging:
  adapter: postgresql
  encoding: unicode
  pool: 25
  database: nykfuel
  username: nykfuel
  password: PPIvkMJki3xP
  host: nykfuel-staging.cmketunlbvea.rds.cn-north-1.amazonaws.com.cn
  template: template0

Run rails server

sudo su

bundle exec unicorn -p 80 --env=staging

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