SSH into Root
$ ssh [email protected]
Change Root Password
$ passwd
Add Deploy User
$ adduser deployer
Add Deployer to sudo group
$ adduser deployer sudo
Configure SSH (Optional)
$ nano /etc/ssh/sshd_config
Port 22 # Change (1025..65536)
Protocol 2 # Change
PermitRootLogin no # Change
UseDNS no # Add
AllowUsers deployer # Add
Reload SSH (Optional)
$ reload ssh
SSH with Deploy User (Don't close root)
$ ssh -p 1026 [email protected]
Install RVM, ImageMagick and other stuff
$ sudo apt-get update
$ sudo apt-get install curl gnupg build-essential git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev libgmp-dev libmagickwand-dev imagemagick libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
$ cd
$ curl -L https://get.rvm.io | bash -s stable
It may ask you to add signatures, add them and repeat last step
$ source ~/.rvm/scripts/rvm
$ rvm install 2.2.3
$ rvm use 2.2.3 --default
$ ruby -v
Install Bundler
$ echo "gem: --no-ri --no-rdoc" > ~/.gemrc
$ gem install bundler
Install NVM + Node.js, latest version ov NVM was 0.30.0, go check the latest one here: https://github.com/creationix/nvm
$ curl https://raw.githubusercontent.com/creationix/nvm/v0.30.0/install.sh | sh
$ source ~/.profile
$ nvm ls-remote
. . .
v4.2.3
v4.2.4
v5.0.0
v5.1.0
. . .
$ nvm install 4.2.4
$ nvm use 4.2.4
$ node -v
Install Rails
$ gem install rails -v 4.2.4
$ rails -v
# Rails 4.2.4
Install PostgreSQL
$ sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
$ wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install postgresql-common
$ sudo apt-get install postgresql-9.3 libpq-dev
Create Postgres User
$ sudo -u postgres psql
create user deployer with password 'password';
alter role deployer superuser createrole createdb replication;
create database MYAPP_production owner deployer;
Install GIT
$ sudo apt-get install git-core
Install Passenger
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
$ sudo apt-get install -y apt-transport-https ca-certificates
$ sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main > /etc/apt/sources.list.d/passenger.list'
$ sudo apt-get update
$ sudo apt-get install -y nginx-extras passenger
Getting passenger_ruby (nginx)
$ passenger-config about ruby-command
passenger-config was invoked through the following Ruby interpreter:
Command: /home/deployer/.rvm/gems/ruby-2.2.3/wrappers/ruby
Version: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
To use in Apache: PassengerRuby /home/deployer/.rvm/gems/ruby-2.2.3/wrappers/ruby
To use in Nginx : passenger_ruby /home/deployer/.rvm/gems/ruby-2.2.3/wrappers/ruby
To use with Standalone: /home/deployer/.rvm/gems/ruby-2.2.3/wrappers/ruby /usr/bin/passenger start
Getting passenger_root
$ passenger-config --root
/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini
Edit Nginx config and setup Passenger
$ sudo nano /etc/nginx/nginx.conf
Uncomment these lines and copy passenger_ruby & passenger_root got above
# passenger_root /some-filename/locations.ini;
# passenger_ruby /usr/bin/passenger_free_ruby;
Add Nginx site
$ sudo nano /etc/nginx/sites-enabled/myapp.conf
server {
listen 80;
server_name yourserver.com;
# Tell Nginx and Passenger where your app's 'public' directory is
root /var/www/myapp/code/public;
# Turn on Passenger
passenger_enabled on;
}