In the previous article, we have seen how to configure DigitalOcean Droplet. Now let's proceed further to set up our application repository and Ngnix with Phusion Passenger on the DigitalOcean droplet.

1. Install RVM and Ruby

We will install ruby using Ruby Version Manager(RVM) as it gives more flexibility to manage multiple ruby versions on the same system over rbenv, chruby, etc. Import RVM GPG key, before installing RVM:

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

Then, install RVM:

curl -sSL https://get.rvm.io | bash -s stable

Load RVM script and run requirement command to manage the installation of required dependencies and files for RVM and Ruby.

source ~/.rvm/scripts/rvm
rvm requirements

Now, install your ruby version. Since I used

rvm install 2.2.1
rvm use 2.2.1 --default

2. Install Nginx and passenger

#Install PGP key and HTTPs support for APT
sudo apt-get install -y dirmngr gnupg
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
sudo apt-get install -y apt-transport-https ca-certificates

# Add our APT repository
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

# Install Passenger + Nginx
sudo apt-get install -y nginx-extras passenger

Open /etc/nginx/nginx.conf file, uncomment include /etc/nginx/passenger.conf; line and save. After finishing with this step, restart Nginx.

sudo service nginx restart

For more information, please visit: PhusionPassenger + Nginx

3. Install Database

Install the database that you'll be using in your Rails app. You can refer to the guide provided by DigitalOcean community to install MySQL or Postgresql database.

4. Install Rails

To install rails run the command:

gem install rails -V --no-ri --no-rdoc

For specific version of Rails:

gem install rails -v '4.2.0' -V --no-ri --no-rdoc

5. Install Bundler

Run the command:

gem install bundler -V --no-ri --no-rdoc

6. Setup SSH Key:

To set up SSH key for authorization on GitHub, run the following command on your droplet server:

ssh -T git@github.com

Add your local machine's public key to your repository's deployment keys. See the instructions here. After this, add your local SSH Key to your Droplet's Authorized Keys file.

cat ~/.ssh/id_rsa.pub | ssh -p your_port_num deploy@your_server_ip 'cat >> ~/.ssh/authorized_keys'

Your comment

*

*