Last Updated: February 25, 2016
·
545
· vano468

Deploying Rails application to a VPS

Updating packages

sudo apt-get update

Installing RVM

curl -L get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm

Installing dependencies

rvm requirements

Installing Ruby

rvm install 2.x.x
rvm use 2.x.x --default

Installing Gems

echo "gem: --no-ri --no-rdoc" > ~/.gemrc
rvm rubygems current
gem install rails
gem install passenger

Installing Nginx/Passenger

apt-get install libcurl4-openssl-dev
rvmsudo passenger-install-nginx-module
sudo service nginx start

If has errors

wget -O init-deb.sh https://www.linode.com/docs/assets/660-init-deb.sh
sudo mv init-deb.sh /etc/init.d/nginx
sudo chmod +x /etc/init.d/nginx
sudo /usr/sbin/update-rc.d -f nginx defaults

Setting up Nginx VH

sudo nano /opt/nginx/conf/nginx.conf

server {
      listen 80;
      server_name localhost;
      passenger_enabled on;
      rails_env production;
      root /home/user/app/public;
}

Installing NodeJS:

sudo apt-get install nodejs
sudo apt-get install npm
ln -s /usr/bin/nodejs /usr/bin/node