Vote for the Student Tech Fund's renewal during the ASUC Elections @ April 5-7!
The OCF is funded by the Student Technology Fund, which will expire if not renewed. read more »
Note: This document only applies to student groups with virtual hosts who have applied for apphosting. For normal user accounts or for groups without apphosting, you'll want to host with FastCGI instead. See our instructions for that here.
You will want to deploy your application using RVM so that you can easily install and manage dependencies and versions.
Create a directory for your app to live in:
mkdir -p ~/myapp cd ~/myapp
Install RVM in your home directory. Note that
rvm is terrible and will
modify your shell config files without asking, but that's probably what you
want, since it will make using and managing Ruby/Rails easier.
Go find the RVM commands appropriate for your app, and copy the lines straight into your shell to install it. In general this is a bad way to install things, but it only has to be done once. At the time of writing, it looks like this:
gpg2 --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3 curl -sSL https://get.rvm.io | bash -s stable
Go ahead and run it, and source
Install whatever version of Ruby you want. (Newer is better).
rvm install ruby-2.4.0 rvm use ruby-2.4.0
Copy your code to
~/myapp/src or similar, and install any dependencies
bundle install (or
gem manually, if you aren't using bundler).
This will download and build whatever gems you have in your
tried to install all the headers (dev packages) needed for building common
gems, but if building a gem fails due to a missing header, just send us an
email so we can add it.
We recommend using unicorn to serve your application. After setting up RVM, add
a few lines to your app's
Gemfile (or add a single line if you already have a
group :production do gem 'unicorn' end
bundle install to install it, as with any new gems.
Create a file at
~/myapp/run with content like:
#!/bin/bash -e . ~/.rvm/scripts/rvm cd ~/myapp/src RAILS_ENV=production \ exec ~/.rvm/gems/ruby-2.4.0/bin/unicorn_rails \ -l /srv/apps/$(whoami)/$(whoami).sock
~/myapp/src with the path to your app (make sure the path is
correct for the version of Ruby you are using), then make
chmod +x ~/myapp/run
Test executing the
run script. You should be able to access your website while
running it (or see any errors in your terminal).
Some things to keep in mind:
config.serve_static_files(rails 4.2), or
config.public_file_server.enabled(rails 5) to true in
Cool, your app works. Set up systemd to supervise your app (so that it starts and restarts automatically).
If you have a better way to host Rails-based apps on the app server (or a suggestion for how we could improve this documentation), send us an email!