Canvas LMSのインストールは、以前に行ったことがあれば簡単です。しかし、初めての場合は難しいかもしれません。Canvas LMSを初めてインストールしようとしている場合は、ぜひこのCanvas LMSインストールガイドをお読みください。ここには、Canvas LMSの本番サーバーを設定するのに役立つ多くの便利なヒントが含まれています。
このガイドでは、 VPS を使用します Ubuntu 24.04 LTS 64ビット. サーバーには8GBのRAMと4つのCPUコアがあります。これはオープンソースのCanvas LMSの最小ハードウェア要件を満たしています。スペックが低いハードウェアにCanvasをインストールすることは推奨しません。インストールが失敗する可能性があります。また、Ubuntu以外のOSを使用することも推奨しません。Windows上でのCanvas LMSのインストールはサポートされていません。
インストールを開始する前に、私たちの Canvas LMS ホスティングサービス. このサービスは、オープンソースのCanvas LMSが事前にインストールされた管理されたクラウドサーバーを提供します。自分のサーバーを設定して管理する手間をかけずにLMSを使用開始できます。
Canvas LMSインストール手順
システムを更新する
まず最初に、サーバーとパッケージを最新バージョンに更新する必要があります。
# sudo apt update && apt upgrade -y
PostgreSQLデータベースサーバーをインストールする
次に、PostgreSQLデータベースサーバーをインストールして構成します。この記事を書いているとき、postgresql-14が利用可能です。
# sudo apt-get install postgresql-14
Add postgresql database and a database user for Canvas. You will be asked to set a password for canvas database user.
# sudo -u postgres createuser canvas --no-createdb \ --no-superuser --no-createrole --pwprompt # sudo -u postgres createdb canvas_production --owner=canvas
サーバーにCanvasコードをダウンロードする
We will use Git to get Canvas code. Install Git if you don’t have it already.
# sudo apt install git-core
このステップでは、Canvas LMSアプリケーション用の別のシステムユーザーを作成します。Canvasコードをダウンロードし、このアカウントの下にインストールします。
# useradd --create-home -s /bin/bash canvas # chmod 711 /home/canvas # su - canvas
Clone files from Canvas Github repository into public_html folder.
$ git clone https://github.com/instructure/canvas-lms.git /home/canvas/public_html $ cd /home/canvas/public_html $ git checkout prod
Canvas LMSの依存関係をインストールします。
Switch back from “canvas” user to a sudo user and install ruby, Node.js, Bundler, Yarn and other Canvas LMS dependencies.
$ sudo apt-get install software-properties-common $ sudo add-apt-repository ppa:instructure/ruby $ sudo apt-get update
Ruby 3.1をインストール
$ sudo apt-get install ruby3.1 ruby3.1-dev zlib1g-dev libxml2-dev \ libsqlite3-dev postgresql libpq-dev \ libxmlsec1-dev libidn11-dev curl make g++
Node.jsをインストール
$ curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - $ sudo apt-get install nodejs $ sudo npm install -g npm@latest
BundlerとRuby Gemsをインストール
# sudo gem install bundler --version 2.3.26 # su - canvas $ cd /home/canvas/public_html $ bundle config set --local path vendor/bundle $ bundle install
Yarnをインストール
# sudo npm -g install yarn
NodeJS依存関係をインストール
# su - canvas $ cd /home/canvas/public_html $ yarn install
Canvas LMSを設定
Canvasのデフォルト設定ファイルをコピー:
$ cd /home/canvas/public_html $ 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
設定ファイルを編集し、関連するデータベース設定、ドメイン設定、送信メールサーバー設定などを入力します。
$ cp config/dynamic_settings.yml.example config/dynamic_settings.yml
$ vim config/dynamic_settings.yml
$ cp config/database.yml.example config/database.yml
$ vim config/database.yml
$ cp config/outgoing_mail.yml.example config/outgoing_mail.yml
$ vim config/outgoing_mail.yml
$ cp config/domain.yml.example config/domain.yml
$ vim config/domain.yml
$ cp config/security.yml.example config/security.yml
$ vim config/security.yml
Canvasデータベースを作成します。
db:initial_setupを実行してデータベーステーブルを作成し、初期データでデータベースをポピュレートします。このステップでは、Canvas管理者ユーザーを作成するよう求められます。
$ mv db/migrate/20210823222355_change_immersive_reader_allowed_on_to_on.rb . $ mv db/migrate/20210812210129_add_singleton_column.rb db/migrate/20111111214311_add_singleton_column.rb $ yarn gulp rev $ RAILS_ENV=production bundle exec rake db:initial_setup $ mv 20210823222355_change_immersive_reader_allowed_on_to_on.rb db/migrate/. $ RAILS_ENV=production bundle exec rake db:migrate
アセットを生成します。
canvas:compile_assetsを実行してテンプレートファイルを生成します。
$ mkdir -p log tmp/pids public/assets app/stylesheets/brandable_css_brands $ touch app/stylesheets/_brandable_variables_defaults_autogenerated.scss $ touch Gemfile.lock $ touch log/production.log
$ RAILS_ENV=production bundle exec rake canvas:compile_assets
ApacheウェブサーバーとPassengerをインストールします。
次に、Canvasを提供するためのウェブサーバーが必要です。NginxとApacheが最も人気のあるオプションです。このガイドではApache + Passengerをインストールします。
$ sudo apt-get install apache2
# Install our PGP key and add HTTPS support for APT sudo apt-get install -y dirmngr gnupg apt-transport-https ca-certificates curl curl https://oss-binaries.phusionpassenger.com/auto-software-signing-gpg-key.txt | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/phusion.gpg >/dev/null # Add our APT repository sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger jammy main > /etc/apt/sources.list.d/passenger.list' sudo apt-get update # Install Passenger + Apache module sudo apt-get install -y libapache2-mod-passenger
Passenger Apacheモジュールを有効にし、Apacheを再起動します。
sudo a2enmod passenger sudo apache2ctl restart
libapache2-mod-passengerのインストールを検証します。以下のコマンドを実行して、passengerとlibapache2-mod-passengerモジュールが正しくインストールされていることを確認してください。
sudo /usr/bin/passenger-config validate-install sudo /usr/sbin/passenger-memory-stats
さらに、apacheのmod_rewriteとmod_sslを有効にします。
$ sudo a2enmod rewrite $ sudo a2enmod ssl
ApacheでCanvasのVirtualHostを設定します。
デフォルトのApache仮想ホスト設定ファイルを無効にし、canvasアプリケーション用の仮想ホスト設定ファイルを作成します。
$ sudo unlink /etc/apache2/sites-enabled/000-default.conf $ sudo vim /etc/apache2/sites-available/canvas.conf
以下の設定をCanvasの仮想ホスト設定ファイルにコピーします。置き換えてください ServerName、ServerAlias、ServerAdmin、DocumentRoot およびその他の設定を、あなたのドメイン名とアプリの場所に合わせて調整します。
<VirtualHost *:80>
ServerName canvas-test.webhostingzone.org
ServerAlias canvasfiles-test.webhostingzone.org
ServerAdmin youremail@example.com
DocumentRoot /home/canvas/public_html/public
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteCond %{REQUEST_URI} !^/health_check
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]
ErrorLog /var/log/apache2/canvas_errors.log
LogLevel warn
CustomLog /var/log/apache2/canvas_access.log combined
PassengerPreloadBundler on
SetEnv RAILS_ENV production
<Directory /home/canvas/public_html/public>
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
# If you are only serving HTTP behind a HTTPS-terminating load balancer, skip the next VirtualHost
<VirtualHost *:443>
ServerName canvas-test.webhostingzone.org
ServerAlias canvasfiles-test.webhostingzone.org
ServerAdmin youremail@example.com
DocumentRoot /home/canvas/public_html/public
ErrorLog /var/log/apache2/canvas_errors.log
LogLevel warn
CustomLog /var/log/apache2/canvas_ssl_access.log combined
SSLEngine on
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
# the following ssl certificate files are generated for you from the ssl-cert package.
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
PassengerPreloadBundler on
SetEnv RAILS_ENV production
<Directory /home/canvas/public_html/public>
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Canvasの仮想ホストを有効にします
$ sudo a2ensite canvas
$ systemctl reload apache2
この時点で、ブラウザを介してCanvasにアクセスできるはずです。ブラウザを開き、指定されたドメイン名を入力してください。 ServerNameCanvasのデフォルトログインページが表示されるはずです。

さらにCanvasの設定手順
ブラウザにCanvasのログインページが読み込まれた場合、これは良い兆候です。しかし、オープンソースのCanvas学習管理システムを本番環境に準備するために、いくつかの調整を完了する必要があります。
Canvas用のSSL証明書をインストールする
When Canvas domain name or sub-domain is pointed to server’s IP address we can proceed and install SSL certificate for Canvas LMS app. For this guide we will install a free LetsEncrypt SSL certificate.
マシンのコマンドラインで以下の指示を実行して、snapdの最新バージョンを持っていることを確認してください。
sudo snap install core; sudo snap refresh core
certbot-autoとすべてのCertbot OSパッケージを削除します。
sudo apt-get remove certbot
Certbotをインストールします。
sudo snap install --classic certbot sudo ln -s /snap/bin/certbot /usr/bin/certbot
certbotを使用してCanvasのSSL証明書をインストールします。
sudo certbot --apache
When SSL certificate is installed correctly you should see a lock icon and text “Connection secure” in a browser when accessing Canvas URI.

Redisキャッシュサーバーをインストールします。
It’s a good idea to install Redis cache server in order to optimize Canvas performance. Redis version 2.6.x or above is required. Add PPA repository and install Redis.
sysadmin@appserver:/var/canvas$ sudo add-apt-repository ppa:chris-lea/redis-server sysadmin@appserver:/var/canvas$ sudo apt-get update sysadmin@appserver:/var/canvas$ sudo apt-get install redis-server
次に、Canvasコードディレクトリに戻り、Redis設定ファイルを編集します。
vim config/cache_store.yml
以下の行をファイルに追加します:
test: cache_store: redis_cache_store development: cache_store: redis_cache_store production: cache_store: redis_cache_store
次に、redis.ymlファイルを編集し、そこにRedisサーバーへのパスを設定します。
vim config/redis.yml
RedisがCanvasと同じサーバーにインストールされている場合、あなたの設定は次のようなものになるはずです。外部サーバーにRedisをインストールした場合は、localhostをRedisサーバーのIPに置き換えてください。
production: servers: - redis://localhost
設定ファイルを保存し、変更を適用するためにCanvasを再起動します。
Canvas用のQTIMigrationToolをインストールします。
Canvasの自動ジョブを設定します。
Canvasの自動ジョブは、レポートを生成したり、メールを送信したりするために実行されている必要があります。次のコマンドは、Canvasの遅延ジョブを構成して開始します。
canvas$ sudo ln -s /home/canvas/public_html/script/canvas_init /etc/init.d/canvas_init canvas$ sudo update-rc.d canvas_init defaults canvas$ sudo /etc/init.d/canvas_init start
リッチコンテンツエディタ用のRCE APIをインストールする
キャンバスインストールエラーのトラブルシューティング
1. アプリケーションは次のエラーに遭遇しました: すでにstrscan 3.0.1がアクティブになっていますが、Gemfileはstrscan 3.0.6を要求しています。strscanはデフォルトのgemであるため、依存関係を削除するか、strscanをデフォルトのgemとしてサポートする新しいバージョンのbundlerに更新することを試みてください。(Gem::LoadError)
Solution: preload Bundler with "PassengerPreloadBundler on" Apache configuration option
2. Common errors during compile assets: FrozenError: can’t modify frozen Array
Solution: delete Canvas project folder, download files from Github again and repeat installation steps.
クレジット
- Canvas Production Start – https://github.com/instructure/canvas-lms/wiki/Production-Start
- Installing Passenger – https://www.phusionpassenger.com/docs/advanced_guides/install_and_upgrade/apache/install/oss/jammy.html
- Canvas LMS Installation Service – https://www.webhostingzone.org/solutions/canvas-lms-installation.html





