Skip to content

Instantly share code, notes, and snippets.

@crmaxx
Forked from alanstevens/install-rvm.sh
Last active September 29, 2016 08:25

Revisions

  1. crmaxx revised this gist Jan 23, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion unicorn-init.sh
    Original file line number Diff line number Diff line change
    @@ -27,7 +27,7 @@ GEM_HOME="/home/ubuntu/.rvm/gems/ruby-1.9.3-p327"
    UNICORN_OPTS="-D -E $ENV -c $APP_ROOT/config/unicorn.rb"

    SET_PATH="cd $APP_ROOT; rvm use ruby-1.9.3-p327@global; export GEM_HOME=$GEM_HOME"
    CMD="$SET_PATH; $GEM_HOME/bin/unicorn $UNICORN_OPTS"
    CMD="$SET_PATH; bundle exec unicorn $UNICORN_OPTS"

    old_pid="$PID.oldbin"

  2. crmaxx revised this gist Jan 23, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion unicorn-init.sh
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,7 @@ GEM_HOME="/home/ubuntu/.rvm/gems/ruby-1.9.3-p327"

    UNICORN_OPTS="-D -E $ENV -c $APP_ROOT/config/unicorn.rb"

    SET_PATH="cd $APP_ROOT; rvm use ruby-1.9.3-p327; export GEM_HOME=$GEM_HOME"
    SET_PATH="cd $APP_ROOT; rvm use ruby-1.9.3-p327@global; export GEM_HOME=$GEM_HOME"
    CMD="$SET_PATH; $GEM_HOME/bin/unicorn $UNICORN_OPTS"

    old_pid="$PID.oldbin"
  3. crmaxx revised this gist Jan 23, 2013. 1 changed file with 75 additions and 0 deletions.
    75 changes: 75 additions & 0 deletions unicorn-init.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,75 @@
    #!/bin/bash
    ### BEGIN INIT INFO
    # Provides: APPLICATION
    # Required-Start: $all
    # Required-Stop: $network $local_fs $syslog
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Start the APPLICATION unicorns at boot
    # Description: Enable APPLICATION at boot time.
    ### END INIT INFO
    #
    # Use this as a basis for your own Unicorn init script.
    # Change APPLICATION to match your app.
    # Make sure that all paths are correct.

    set -u
    set -e

    # Change these to match your app:
    APP_NAME=APPLICATION
    APP_ROOT="/srv/ror/$APP_NAME/current"
    PID="/srv/ror/$APP_NAME/shared/pids/unicorn.pid"
    ENV=production

    GEM_HOME="/home/ubuntu/.rvm/gems/ruby-1.9.3-p327"

    UNICORN_OPTS="-D -E $ENV -c $APP_ROOT/config/unicorn.rb"

    SET_PATH="cd $APP_ROOT; rvm use ruby-1.9.3-p327; export GEM_HOME=$GEM_HOME"
    CMD="$SET_PATH; $GEM_HOME/bin/unicorn $UNICORN_OPTS"

    old_pid="$PID.oldbin"

    cd $APP_ROOT || exit 1

    sig () {
    test -s "$PID" && kill -$1 `cat $PID`
    }

    oldsig () {
    test -s $old_pid && kill -$1 `cat $old_pid`
    }

    case ${1-help} in
    start)
    sig 0 && echo >&2 "Already running" && exit 0
    su - unicorn -c "$CMD"
    ;;
    stop)
    sig QUIT && exit 0
    echo >&2 "Not running"
    ;;
    force-stop)
    sig TERM && exit 0
    echo >&2 "Not running"
    ;;
    restart|reload)
    sig HUP && echo reloaded OK && exit 0
    echo >&2 "Couldn't reload, starting '$CMD' instead"
    su - unicorn -c "$CMD"
    ;;
    upgrade)
    sig USR2 && exit 0
    echo >&2 "Couldn't upgrade, starting '$CMD' instead"
    su - unicorn -c "$CMD"
    ;;
    rotate)
    sig USR1 && echo rotated logs OK && exit 0
    echo >&2 "Couldn't rotate logs" && exit 1
    ;;
    *)
    echo >&2 "Usage: $0 <start|stop|restart|upgrade|rotate|force-stop>"
    exit 1
    ;;
    esac
  4. crmaxx revised this gist Jan 23, 2013. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions 0-readme.md
    Original file line number Diff line number Diff line change
    @@ -64,4 +64,9 @@ bash -s < <(curl -s https://raw.github.com/gist/4598302/install-rvm.sh)
    Install nginx
    ```bash
    sudo apt-get install nginx
    ```
    Create dir for projects
    ```bash
    sudo mkdir -p /srv/ror
    sudo chown -R ubuntu:ubuntu /srv/ror/
    ```
  5. crmaxx revised this gist Jan 23, 2013. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions 0-readme.md
    Original file line number Diff line number Diff line change
    @@ -59,4 +59,9 @@ source ~/.bash_profile
    Install rvm & ruby & rails
    ```bash
    bash -s < <(curl -s https://raw.github.com/gist/4598302/install-rvm.sh)
    ```
    ### Install web-server
    Install nginx
    ```bash
    sudo apt-get install nginx
    ```
  6. crmaxx revised this gist Jan 23, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions install-rvm.sh
    Original file line number Diff line number Diff line change
    @@ -11,8 +11,8 @@ source ~/.bash_profile
    echo 'Installing ruby 1.9.3-p327 with falcon-gc patch'
    rvm get head
    rvm install 1.9.3-p327 --patch falcon-gc
    rvm use 1.9.3-p327 --default
    rvm use 1.9.3-p327@global
    rvm use ruby-1.9.3-p327 --default
    rvm use ruby-1.9.3-p327@global
    echo 'Installing rails'
    gem install rails --no-rdoc --no-ri
    echo 'Installing bundler'
  7. crmaxx revised this gist Jan 23, 2013. 1 changed file with 9 additions and 4 deletions.
    13 changes: 9 additions & 4 deletions 0-readme.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    # Amazon AWS EC2 production for Ruby on Rails
    ## Prepare cloud
    ### Speed up ssh login
    ```bash
    echo 'UseDNS no # if slow connection' >> /etc/ssh/sshd_config
    echo 'PrintMotd yes # if you need motd messages' >> /etc/ssh/sshd_config
    @@ -7,15 +9,17 @@ From /etc/pam.d/login && /etc/pam.d/sshd delete all strings included
    ```
    session optional pam_motd.so
    ```
    Update fresh installed cloud
    ```bash
    sudo apt-get update && sudo apt-get upgrade
    ```
    Remove components of paid monitoring
    ```bash
    sudo apt-get remove landscape-client landscape-common
    sudo apt-get autoremove
    ```
    ## Installation
    ### Prepare ubuntu
    Update fresh installed cloud
    ```bash
    sudo apt-get update && sudo apt-get upgrade
    ```
    Install utilities
    ```bash
    sudo apt-get install mc htop curl git-core localepurge
    @@ -51,6 +55,7 @@ sudo apt-get install libtcmalloc-minimal0
    echo 'export LD_PRELOAD=/usr/lib/libtcmalloc_minimal.so.0.1.0' >> ~/.bash_profile
    source ~/.bash_profile
    ```
    ### Install ruby env
    Install rvm & ruby & rails
    ```bash
    bash -s < <(curl -s https://raw.github.com/gist/4598302/install-rvm.sh)
  8. crmaxx revised this gist Jan 23, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 0-readme.md
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ Update fresh installed cloud
    ```bash
    sudo apt-get update && sudo apt-get upgrade
    ```
    Removes a component of paid monitoring
    Remove components of paid monitoring
    ```bash
    sudo apt-get remove landscape-client landscape-common
    sudo apt-get autoremove
  9. crmaxx revised this gist Jan 23, 2013. 2 changed files with 5 additions and 7 deletions.
    2 changes: 1 addition & 1 deletion 0-readme.md
    Original file line number Diff line number Diff line change
    @@ -48,7 +48,7 @@ alter user username superuser;
    Install alternative malloc. Ruby works on 8-10% faster.
    ```bash
    sudo apt-get install libtcmalloc-minimal0
    echo 'export LD_PRELOAD=/usr/lib64/libtcmalloc_minimal.so.0.1.0' >> ~/.bash_profile
    echo 'export LD_PRELOAD=/usr/lib/libtcmalloc_minimal.so.0.1.0' >> ~/.bash_profile
    source ~/.bash_profile
    ```
    Install rvm & ruby & rails
    10 changes: 4 additions & 6 deletions install-rvm.sh
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,18 @@
    #!/bin/bash
    echo 'Installing RVM'
    bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
    echo 'Prepare ENV'
    echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
    echo '# Ruby tuning' >> ~/.bash_profile
    echo 'export RUBY_HEAP_MIN_SLOTS=1000000' >> ~/.bash_profile
    echo 'export RUBY_HEAP_SLOTS_INCREMENT=1000000' >> ~/.bash_profile
    echo 'export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1' >> ~/.bash_profile
    echo 'export RUBY_GC_MALLOC_LIMIT=1000000000' >> ~/.bash_profile
    echo 'export RUBY_HEAP_FREE_MIN=500000' >> ~/.bash_profile
    source ~/.bash_profile
    echo 'Installing ruby 1.9.3-perf with falcon patch'
    echo 'Installing ruby 1.9.3-p327 with falcon-gc patch'
    rvm get head
    rvm install 1.9.3-perf --patch falcon
    rvm use 1.9.3-perf --default
    rvm use 1.9.3-perf@global
    rvm install 1.9.3-p327 --patch falcon-gc
    rvm use 1.9.3-p327 --default
    rvm use 1.9.3-p327@global
    echo 'Installing rails'
    gem install rails --no-rdoc --no-ri
    echo 'Installing bundler'
  10. crmaxx revised this gist Jan 23, 2013. 2 changed files with 7 additions and 3 deletions.
    8 changes: 7 additions & 1 deletion 0-readme.md
    Original file line number Diff line number Diff line change
    @@ -45,7 +45,13 @@ Grant privelegies for it.
    ```sql
    alter user username superuser;
    ```
    Install alternative malloc. Ruby works on 8-10% faster.
    ```bash
    sudo apt-get install libtcmalloc-minimal0
    echo 'export LD_PRELOAD=/usr/lib64/libtcmalloc_minimal.so.0.1.0' >> ~/.bash_profile
    source ~/.bash_profile
    ```
    Install rvm & ruby & rails
    ```bash
    curl https://raw.github.com/gist/4598302/install-rvm.sh | sh
    bash -s < <(curl -s https://raw.github.com/gist/4598302/install-rvm.sh)
    ```
    2 changes: 0 additions & 2 deletions install-rvm.sh
    Original file line number Diff line number Diff line change
    @@ -9,8 +9,6 @@ echo 'export RUBY_HEAP_SLOTS_INCREMENT=1000000' >> ~/.bash_profile
    echo 'export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1' >> ~/.bash_profile
    echo 'export RUBY_GC_MALLOC_LIMIT=1000000000' >> ~/.bash_profile
    echo 'export RUBY_HEAP_FREE_MIN=500000' >> ~/.bash_profile
    apt-get install libtcmalloc-minimal0
    echo 'export LD_PRELOAD=/usr/lib64/libtcmalloc_minimal.so.0.1.0' >> ~/.bash_profile
    source ~/.bash_profile
    echo 'Installing ruby 1.9.3-perf with falcon patch'
    rvm get head
  11. crmaxx revised this gist Jan 23, 2013. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions 0-readme.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    *Amazon AWS EC2 production for Ruby on Rails
    # Amazon AWS EC2 production for Ruby on Rails
    ```bash
    cat 'UseDNS no # if slow connection' >> /etc/ssh/sshd_config
    cat 'PrintMotd yes # if you need motd messages' >> /etc/ssh/sshd_config
    echo 'UseDNS no # if slow connection' >> /etc/ssh/sshd_config
    echo 'PrintMotd yes # if you need motd messages' >> /etc/ssh/sshd_config
    ```
    From /etc/pam.d/login && /etc/pam.d/sshd delete all strings included
    ```
  12. crmaxx revised this gist Jan 23, 2013. 2 changed files with 39 additions and 5 deletions.
    42 changes: 38 additions & 4 deletions 0-readme.md
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,51 @@
    *Amazon AWS EC2 production for Ruby on Rails
    ```bash
    cat 'UseDNS no # if slow connection' >> /etc/ssh/sshd_config
    cat 'PrintMotd yes # if you need motd messages' >> /etc/ssh/sshd_config
    ```
    From /etc/pam.d/login && /etc/pam.d/sshd delete all strings included
    ```
    session optional pam_motd.so
    ```
    Update fresh installed cloud
    ```bash
    sudo apt-get update && sudo apt-get upgrade
    ```
    Removes a component of paid monitoring
    ```bash
    sudo apt-get remove landscape-client landscape-common
    sudo apt-get autoremove
    sudo apt-get install mc htop curl git-core
    ```
    Install utilities
    ```bash
    sudo apt-get install mc htop curl git-core localepurge
    ```
    Install devtools
    ```bash
    sudo apt-get install build-essential bison openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev
    ```
    Install postgresql
    ```bash
    sudo add-apt-repository ppa:pitti/postgresql && sudo apt-get update
    sudo apt-get install postgresql-9.2 postgresql-client-9.2 postgresql-contrib-9.2 postgresql-server-dev-9.2
    sudo netstat -lp | grep postgresql # port must be 5432
    ```
    Check pg port. It must be 5432
    ```bash
    sudo netstat -lp | grep postgresql
    ```
    Connect to pg via psql
    ```bash
    sudo su postgres -c psql
    ```
    Create a new user
    ```sql
    create user username with password 'password';
    ```
    Grant privelegies for it.
    ```sql
    create user username with password 'password';
    alter user username superuser;
    ```

    Install rvm & ruby & rails
    ```bash
    curl https://raw.github.com/gist/4598302/install-rvm.sh | sh
    ```
    2 changes: 1 addition & 1 deletion install-rvm.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #!/bin/bash
    echo 'Installing RVM'
    bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
    bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
    echo 'Prepare ENV'
    echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
    echo '# Ruby tuning' >> ~/.bash_profile
  13. crmaxx revised this gist Jan 23, 2013. 1 changed file with 14 additions and 0 deletions.
    14 changes: 14 additions & 0 deletions 0-readme.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,17 @@
    ```bash
    sudo apt-get update && sudo apt-get upgrade
    sudo apt-get remove landscape-client landscape-common
    sudo apt-get autoremove
    sudo apt-get install mc htop curl git-core
    sudo add-apt-repository ppa:pitti/postgresql && sudo apt-get update
    sudo apt-get install postgresql-9.2 postgresql-client-9.2 postgresql-contrib-9.2 postgresql-server-dev-9.2
    sudo netstat -lp | grep postgresql # port must be 5432
    sudo su postgres -c psql
    ```
    ```sql
    create user username with password 'password';
    ```

    ```bash
    curl https://raw.github.com/gist/4598302/install-rvm.sh | sh
    ```
  14. crmaxx revised this gist Jan 22, 2013. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion 0-readme.md
    Original file line number Diff line number Diff line change
    @@ -1 +1,3 @@
    curl https://raw.github.com/gist/4598302/install-rvm.sh | sh
    ```bash
    curl https://raw.github.com/gist/4598302/install-rvm.sh | sh
    ```
  15. crmaxx revised this gist Jan 22, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions 0-readme.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    curl https://raw.github.com/gist/4598302/install-rvm.sh | sh
  16. crmaxx revised this gist Jan 22, 2013. 1 changed file with 18 additions and 3 deletions.
    21 changes: 18 additions & 3 deletions install-rvm.sh
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,26 @@
    #!/bin/bash
    echo 'Installing RVM'
    bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
    echo 'Prepare ENV'
    echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
    echo '# Ruby tuning' >> ~/.bash_profile
    echo 'export RUBY_HEAP_MIN_SLOTS=1000000' >> ~/.bash_profile
    echo 'export RUBY_HEAP_SLOTS_INCREMENT=1000000' >> ~/.bash_profile
    echo 'export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1' >> ~/.bash_profile
    echo 'export RUBY_GC_MALLOC_LIMIT=1000000000' >> ~/.bash_profile
    echo 'export RUBY_HEAP_FREE_MIN=500000' >> ~/.bash_profile
    apt-get install libtcmalloc-minimal0
    echo 'export LD_PRELOAD=/usr/lib64/libtcmalloc_minimal.so.0.1.0' >> ~/.bash_profile
    source ~/.bash_profile
    rvm install 1.9.3-falcon --patch falcon
    rvm use 1.9.3-falcon --default
    rvm use 1.9.3-falcon@global
    echo 'Installing ruby 1.9.3-perf with falcon patch'
    rvm get head
    rvm install 1.9.3-perf --patch falcon
    rvm use 1.9.3-perf --default
    rvm use 1.9.3-perf@global
    echo 'Installing rails'
    gem install rails --no-rdoc --no-ri
    echo 'Installing bundler'
    gem install bundler --no-rdoc --no-ri
    echo 'Creating ~/.gemrc'
    echo "install: --no-rdoc --no-ri" >> ~/.gemrc
    echo "update: --no-rdoc --no-ri" >> ~/.gemrc
  17. crmaxx revised this gist Jan 22, 2013. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions install-rvm.sh
    Original file line number Diff line number Diff line change
    @@ -2,9 +2,9 @@
    bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
    echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
    source ~/.bash_profile
    rvm install 1.9.2
    rvm use 1.9.2 --default
    rvm use 1.9.2@global
    rvm install 1.9.3-falcon --patch falcon
    rvm use 1.9.3-falcon --default
    rvm use 1.9.3-falcon@global
    gem install rails --no-rdoc --no-ri
    gem install bundler --no-rdoc --no-ri
    echo "install: --no-rdoc --no-ri" >> ~/.gemrc
  18. @alanstevens alanstevens revised this gist Mar 14, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions install-rvm.sh
    Original file line number Diff line number Diff line change
    @@ -7,3 +7,5 @@ rvm use 1.9.2 --default
    rvm use 1.9.2@global
    gem install rails --no-rdoc --no-ri
    gem install bundler --no-rdoc --no-ri
    echo "install: --no-rdoc --no-ri" >> ~/.gemrc
    echo "update: --no-rdoc --no-ri" >> ~/.gemrc
  19. @alanstevens alanstevens created this gist Dec 20, 2011.
    9 changes: 9 additions & 0 deletions install-rvm.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    #!/bin/bash
    bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
    echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
    source ~/.bash_profile
    rvm install 1.9.2
    rvm use 1.9.2 --default
    rvm use 1.9.2@global
    gem install rails --no-rdoc --no-ri
    gem install bundler --no-rdoc --no-ri