Canvas LMSのQuick Startを試す(Ubuntu/xenial)
公式ドキュメントが全然使えない
Canvas LMSのお試し環境を作ろうと思い、公式ドキュメントの手順で構築を試みた。しかしドキュメントが更新されていないのか、何度試しても途中で詰まってしまう。そもそも同じドキュメントでRubyのバージョンが異なっていたり、yarnのバージョン指定が無いなどの不備があるので、ドキュメントとしてあまり正確な内容ではないのだろう。(2017/12/24時点の話) github.com
今回の構築環境
あくまでもお試し環境を作るだけなので、VagrantでUbuntu環境を構築する。 メモリ容量は4GBくらい確保しておけば良い。容量が足りないとビルド中にエラーになる。IPアドレスの設定値はご自由に。
Vagrantfile
# -*- mode: ruby -*- # vi: set ft=ruby : # All Vagrant configuration is done below. The "2" in Vagrant.configure # configures the configuration version (we support older styles for # backwards compatibility). Please don't change it unless you know what # you're doing. Vagrant.configure("2") do |config| # The most common configuration options are documented and commented below. # For a complete reference, please see the online documentation at # https://docs.vagrantup.com. # Every Vagrant development environment requires a box. You can search for # boxes at https://vagrantcloud.com/search. config.vm.box = "ubuntu/xenial64" # Disable automatic box update checking. If you disable this, then # boxes will only be checked for updates when the user runs # `vagrant box outdated`. This is not recommended. # config.vm.box_check_update = false # Create a forwarded port mapping which allows access to a specific port # within the machine from a port on the host machine. In the example below, # accessing "localhost:8080" will access port 80 on the guest machine. # NOTE: This will enable public access to the opened port # config.vm.network "forwarded_port", guest: 80, host: 8080 # Create a forwarded port mapping which allows access to a specific port # within the machine from a port on the host machine and only allow access # via 127.0.0.1 to disable public access # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" # Create a private network, which allows host-only access to the machine # using a specific IP. config.vm.network "private_network", ip: "192.168.33.20" # Create a public network, which generally matched to bridged network. # Bridged networks make the machine appear as another physical device on # your network. # config.vm.network "public_network" # Share an additional folder to the guest VM. The first argument is # the path on the host to the actual folder. The second argument is # the path on the guest to mount the folder. And the optional third # argument is a set of non-required options. # config.vm.synced_folder "../data", "/vagrant_data" # Provider-specific configuration so you can fine-tune various # backing providers for Vagrant. These expose provider-specific options. # Example for VirtualBox: # config.vm.provider "virtualbox" do |vb| # # Display the VirtualBox GUI when booting the machine # vb.gui = true # # # Customize the amount of memory on the VM: vb.memory = "4096" end # # View the documentation for the provider you are using for more # information on available options. # Enable provisioning with a shell script. Additional provisioners such as # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the # documentation for more information about their specific syntax and use. # config.vm.provision "shell", inline: <<-SHELL # apt-get update # apt-get install -y apache2 # SHELL end
ミドルウェアのインストール作業
CODES.shという構築スクリプトが用意されているが、これも何故か動かなかったので自分で一から構築する。
仮想マシンが起動したら、まずaptで必要なものを入れる。
curl -sL https://deb.nodesource.com/setup_6.x | sudo bash - sudo add-apt-repository ppa:brightbox/ruby-ng 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 ruby2.4 ruby2.4-dev postgresql nodejs libxmlsec1-dev \ zlib1g-dev libxml2-dev libsqlite3-dev libpq-dev curl make g++ redis-server sudo apt-get install yarn=0.27.5-1
インストールしたRedisはとりあえず、裏で動かしておけば良い。
sudo redis-server &
postgresのインストール後に、postgres上にユーザを作成する。
sudo -u postgres createuser $USER sudo -u postgres psql -c "alter user $USER with superuser" postgres
Rubyのインストール後に、Bundlerをインストールする。バージョンによっては後々面倒なことになるので、必ずバージョン指定すること。
sudo gem install bundler -v 1.14.6
Canvas LMSのソースコードを、Githubのリポジトリからクローンする。
git clone https://github.com/instructure/canvas-lms.git canvas cd canvas
Bundlerとnpmのインストール後に、Canvas LMSに必要なモジュールをインストールする。
bundle install npm install
npmでCoffeeScriptをインストールする。
sudo npm install -g coffee-script@1.6.2
設定ファイルのコピー
アプリケーションのサンプル設定ファイルを、使用する設定ファイルとしてコピーする。Quick Startでは特に編集しなくて良い。
for config in amazon_s3 delayed_jobs domain file_store outgoing_mail security external_migration; \ do cp -v config/$config.yml.example config/$config.yml; done cp config/dynamic_settings.yml.example config/dynamic_settings.yml cp config/database.yml.example config/database.yml echo -e "development:\n cache_store: redis_store" > config/cache_store.yml echo -e "development:\n servers:\n - redis://localhost" > config/redis.yml
DBテーブルの作成
Canvas LMSで使用するテーブルを作成する。
createdb canvas_development
Canvas LMSのビルド
ようやくCanvas LMS自体のビルドを行っていく。
bundle exec rails canvas:compile_assets bundle exec rails db:initial_setup
initial_setup後にエラーが出るが、めげずにもう一度同じコマンドを叩く。
bundle exec rails db:initial_setup
そうすると管理者のメールアドレスとパスワードを聞かれるので入力する。 この際に8500ポートに接続失敗したとか何とか言われるが、めげずにもう一度ログイン情報を入力するとインストールが完了する。
エラー内容
Problem creating administrative account, please try again: Connection refused - Connection refused - connect(2) for "localhost" port 8500 (localhost:8500)
ビルド時のエラーと管理者情報入力時のエラーが何故出力されるのかは不明で、issueも今のところ上がっていない。
Canvas LMSを起動
IPアドレスを明示的に指定しないと、ホストマシンからアクセスできないので注意すること。
bundle exec rails server -b 0.0.0.0