Deploying a Ruby on Rails application

Start the MySQL daemon if not already started:

 systemctl start mysql

Change into the webroot, backup the example railsapp and replace it with the to be deployed Rails application:

cd /var/www
mv railsapp railsapp.orig
mv /path/to/NEW_APP /var/www/railsapp

TurnKey Ruby-on-Rails appliance uses rbenv to install Ruby. By default, if it already locally has the Ruby version noted in your project's '.ruby-version' file, you should be good. Although you may need to install the desired Ruby version as required. Here are some commands that give some insight into that process:

# list latest stable versions:
rbenv install -l

# list all local versions:
rbenv install -L

# install a Ruby version:
rbenv install 2.0.0-p247

Initialize the database:

cp railsapp.orig/config/database.yml railsapp/config/
cd /var/www/railsapp
rake db:migrate RAILS_ENV="production"

Create the tmp directory (if missing):

mkdir -p tmp

Configure permissions:

chown -R root:www-data /var/www/railsapp
chown -R www-data:www-data /var/www/railsapp/tmp
chown -R www-data:www-data /var/www/railsapp/log
chmod 666 /var/www/railsapp/log/*

Optionally remove the example railsapp, and restart the database and webserver:

rm -rf /var/www/railsapp.orig
systemctl restart mysql
systemctl restart apache2


Thats it, you're done!