Skip to content

Deploying Autolab on Ubuntu

Jake Zimmerman edited this page Apr 20, 2015 · 5 revisions

Hey There!

These are the instructions for setting up Autolab for production usage. It's the closest to the way we run Autolab for our CMU Autolab instance, but it's certainly not the fastest way to get up and running with a version of Autolab that you can play around with. Be sure to check out "Getting Started" in the sidebar if this is your first experience with Autolab.

Overview

Rather than explicit instructions, this documentation should be treated as "tips" for deploying Rails. For example, we use Apache at CMU, but there's really nothing stopping you from running Nginx or your favorite web server.

Jumping In

Without further ado, let's get started!

1. Install Apache

Make sure you have Apache installed. If you set up Ubuntu Server as a LAMP server, you already have it installed.

2. Follow the Installing Autolab on Ubuntu instructions

You're going to want to follow the Installing Autolab on Ubuntu instructions. This article covers how to install Autolab for development, so you should make the following notes when running through them and adjust your actions accordingly:

  • Login as apache or www-data user before installing rbenv and ruby-build.
  • When installing rbenv, if you get a Permission denied error when you restart the shell, add
    export RBENV_ROOT="$HOME/rbenv"
    
    before rbenv init - in your ~/.bashrc. Otherwise, skip the next remark.
  • When installing ruby-build, if you set RBENV_ROOT in the step above, make sure to clone the ruby-build plugin to $HOME/rbenv/plugins.
  • Make the Apache user & group you set in Step 1 the user & group of the Autolab project directory. There's no need to modify permissions.

Make sure the development version runs before going on to the next step.

3. Setup Autolab VirtualHost

You're going to want to set up the Autolab VirtualHost at port 443 (HTTPS). Here's what our VirtualHost config file look like:

<VirtualHost _default_:443>

	DocumentRoot /path/to/Autolab/public
	<Directory /path/to/Autolab/public>
		Allow from all
		AllowOverride all
		Options -MultiViews
	</Directory>

 	#   Uncomment these two lines if you want to 
	#   customize log path
	#ErrorLog /path/to/error_log
	#CustomLog /path/to/access_log combined

	#   SSL Engine Switch:
	#   Enable/Disable SSL for this virtual host.
	SSLEngine on

	#   A self-signed (snakeoil) certificate can be created by installing
	#   the ssl-cert package. See
	#   /usr/share/doc/apache2.2-common/README.Debian.gz for more info.
	#   If both key and certificate are stored in the same file, only the
	#   SSLCertificateFile directive is needed.
	SSLCertificateFile    /path/to/certificate.pem
	SSLCertificateKeyFile /path/to/certificate.key

</VirtualHost>

Then, run sudo a2enmod ssl to enable the ssl module.

4. Install passenger for Autolab

First, install the passenger gem:

$ gem install passenger

Then, execute

$ passenger-install-apache2-module

to install the passenger Apache module. Follow the on-screen instructions to load passenger in Apache.

5. Wrap up

At this time you should be able to see Autolab running on the HTTPS port. Run RAILS_ENV=production rake assets:precompile if you can't see images on the website.

Optional: Setup Administrator

  1. Sign up on the Autolab website just set up.

  2. Run RAILS_ENV=production rails console under Autolab directory.

  3. In the console, run the following command:

    u = User.where(email: "[your email here]").first
    u.administrator = true
    u.save!
  4. Next time you sign in to Autolab, you should be able to create courses.