(Last Updated On: February 24, 2019)

Welcome to our guide on how to install Canvas LMS on Ubuntu 18.04. Canvas is a modern, open-source LMS (Learning Management System) developed and maintained by Instructure Inc. The software is free for use by anyone interested and is released under the AGPLv3 license.

Canvas Software Requirements

Canvas LMS depend on the following software packages to run.

  • Apache Web Server
  • Ruby on Rails
  • PostgreSQL database server

Here are the steps of installing and configuring the Canvas Learning Management System on Ubuntu 18.04 LTS.

Automatic Installation of Canvas

The automatic installation method uses Docker container to run Canvas services.

Install Docker

Run below commands to install the latest release of Docker which works fine for Discourse.

wget -qO- https://get.docker.com/ | sh

If you would like to use Docker as a non-root user, you should now consider adding your user to the “docker” group with:

sudo usermod -aG docker username

You can query for installed version using the command below.

$ docker version
Client:
Version: 18.09.2
API version: 1.39
Go version: go1.10.6
Git commit: 6247962
Built: Sun Feb 10 04:13:47 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.2
API version: 1.39 (minimum version 1.12)
Go version: go1.10.6
Git commit: 6247962
Built: Sun Feb 10 03:42:13 2019
OS/Arch: linux/amd64
Experimental: false

Docker should be in a running status.

$ systemctl status  docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2019-02-23 08:55:15 CET; 1min 54s ago
Docs: https://docs.docker.com
Main PID: 28222 (dockerd)
Tasks: 8
CGroup: /system.slice/docker.service
└─28222 /usr/bin/dockerd -H fd://
Feb 23 08:55:14 ubuntu-2gb-nbg1-1 dockerd[28222]: time="2019-02-23T08:55:14.792931869+01:00" level=warning msg="Your kernel does not support swap memor
Feb 23 08:55:14 ubuntu-2gb-nbg1-1 dockerd[28222]: time="2019-02-23T08:55:14.793210296+01:00" level=warning msg="Your kernel does not support cgroup rt
Feb 23 08:55:14 ubuntu-2gb-nbg1-1 dockerd[28222]: time="2019-02-23T08:55:14.793354019+01:00" level=warning msg="Your kernel does not support cgroup rt
Feb 23 08:55:14 ubuntu-2gb-nbg1-1 dockerd[28222]: time="2019-02-23T08:55:14.795671966+01:00" level=info msg="Loading containers: start."
Feb 23 08:55:14 ubuntu-2gb-nbg1-1 dockerd[28222]: time="2019-02-23T08:55:14.946891414+01:00" level=info msg="Default bridge (docker0) is assigned with
Feb 23 08:55:15 ubuntu-2gb-nbg1-1 dockerd[28222]: time="2019-02-23T08:55:15.019658891+01:00" level=info msg="Loading containers: done."
Feb 23 08:55:15 ubuntu-2gb-nbg1-1 dockerd[28222]: time="2019-02-23T08:55:15.117287717+01:00" level=info msg="Docker daemon" commit=6247962 graphdriver(
Feb 23 08:55:15 ubuntu-2gb-nbg1-1 dockerd[28222]: time="2019-02-23T08:55:15.117884716+01:00" level=info msg="Daemon has completed initialization"
Feb 23 08:55:15 ubuntu-2gb-nbg1-1 systemd[1]: Started Docker Application Container Engine.
Feb 23 08:55:15 ubuntu-2gb-nbg1-1 dockerd[28222]: time="2019-02-23T08:55:15.153778133+01:00" level=info msg="API listen on /var/run/docker.sock"

Clone the repository:

git clone https://github.com/instructure/canvas-lms.git

Then run installer script.

$ cd canvas-lms
$ ./script/docker_dev_setup.sh

  ________  ________  ________   ___      ___ ________  ________
|\   ____\|\   __  \|\   ___  \|\  \    /  /|\   __  \|\   ____\
\ \  \___|\ \  \|\  \ \  \\ \  \ \  \  /  / | \  \|\  \ \  \___|_
 \ \  \    \ \   __  \ \  \\ \  \ \  \/  / / \ \   __  \ \_____  \
  \ \  \____\ \  \ \  \ \  \\ \  \ \    / /   \ \  \ \  \|____|\  \
   \ \_______\ \__\ \__\ \__\\ \__\ \__/ /     \ \__\ \__\____\_\  \
    \|_______|\|__|\|__|\|__| \|__|\|__|/       \|__|\|__|\_________\
                                                         \|_________|

Welcome! This script will guide you through the process of setting up a
Canvas development environment with docker and dinghy/dory.

When you git pull new changes, you can run ./scripts/docker_dev_update.sh
to bring everything up to date.

> First, we need to install some dependencies.
OK to run 'sudo apt-get update && sudo apt-get install -y docker-compose'? [y/n] y

Agree to all other prompts to finish the installation of Canvas LMS.

Manual Installation of Canvas

For manual installation of Canvas LMS on Ubuntu 18.04, use the steps below.

Step 1: Install Canvas dependencies

Here we will install Ruby and Node.js software packages. Let’s start with the installation of Node.js.

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install nodejs

Supported Ruby version is on a PPA repository, add it like below.

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:brightbox/ruby-ng
sudo apt-get update
sudo apt-get install ruby2.4 ruby2.4-dev zlib1g-dev libxml2-dev \
libsqlite3-dev postgresql libpq-dev \
libxmlsec1-dev curl make g++

Confirm ruby version.

$ ruby -v
ruby 2.4.5p335 (2018-10-18 revision 65137) [x86_64-linux-gnu]

Finally install Yarn.

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn=1.10.1-1

Step 2: Install PostgreSQL database server

Canvas uses PostgreSQL to store its data. Install PostgreSQL on Ubuntu 18.04 using our guide below.

Install PostgreSQL on Ubuntu 18.04

Once the database server is installed, create database for Canvas and user named canvas.

$ sudo su postgres
$ createuser canvas --no-createdb \
--no-superuser --no-createrole --pwprompt

Provide user password and confirm when prompted. Then create canvas database.

$ createdb canvas --owner=canvas

You can optionally set your system username as a postgres superuser.

sudo -u postgres createuser $USER
sudo -u postgres psql -c "alter user $USER with superuser" postgres

Step 3: Clone Canvas LMS project

Clone the latest source for Canvas.

git clone https://github.com/instructure/canvas-lms.git /var/canvas

Checkout stable branch.

cd /var/canvas
git checkout stable

Step 4: Configure Canvas

Change to /var/canvas directory and pull in the default configuration values.

cd /var/canvas
for config in amazon_s3 database \
delayed_jobs domain file_store outgoing_mail security external_migration; \
do cp config/$config.yml.example config/$config.yml; done

Do the same for Database and Dynamic settings.

cp config/dynamic_settings.yml.example config/dynamic_settings.yml
cp config/database.yml.example config/database.yml

Edit the file config/database.yml and set your Canvas Database credentials.

..........
production:
adapter: postgresql
encoding: utf8
database: canvas
host: localhost
username: canvas
password: password
timeout: 5000

Install Bundler using Ruby Gems:

$ gem install bundler -v 1.13.6

Install Canvas Dependencies

cd /var/canvas
bundle install
yarn install --pure-lockfile && yarn install --pure-lockfile
sudo npm install -g [email protected]

Population database with tables and data.

bundle exec rails db:initial_setup

Sample output is as shown below.

Build a number of Canvas assets using:

bundle exec rails canvas:compile_assets

Finally start the Canvas server.

bundle exec rails server