欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

基于docker?部署canvas-lms的詳細(xì)步驟

 更新時(shí)間:2022年03月21日 08:43:30   作者:error250  
這篇文章主要介紹了基于docker?部署?canvas-lms,本文分步驟給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

準(zhǔn)備: 一臺(tái)8G內(nèi)存的服務(wù)器。安裝好docker, pull一個(gè)ubuntu鏡像下來(lái), 可以是最新版也可以是官方支持的14/ 16

更新時(shí)間: 2018-04-04

Step 1: 啟動(dòng)docker然后加載ubuntu鏡像。命令如下:

sudo docker run -it ubuntu # -it 是鏈接輸入輸出, 后面有一個(gè)command參數(shù), 默認(rèn)為/bin/bash

Step 2: 安裝vim, sudo (ubuntu鏡像可能會(huì)非常精簡(jiǎn), 沒(méi)有sudo, 沒(méi)有vim等文本編輯器)

apt-get update && apt-get install vim sudo  # 先update不然可能找不到軟件

Step 3: 添加一個(gè)用戶(hù), 然后加入到sudo列表

useradd canvas_user
passwd canvas_user  # 修改密碼
vim /etc/sudoers

Step 4: 安裝postgresql, 版本>=9.3

sudo apt-get install -y postgresql

Step 5: 配置postgresql

sudo -u postgres createuser canvas -D -S -R -P   # 給canvas用戶(hù)設(shè)置登錄密碼
sudo -u postgres createdb canvas_production --owner=canvas
sudo -u postgres createdb canvas_queue_production --owner=canvas

驗(yàn)證數(shù)據(jù)庫(kù)是否配置成功:

psql -h localhost -U canvas canvas_production
psql -h localhost -U canvas canvas_queue_production

Step 6: 安裝git

sudo apt-get install git-core

Step 7: 獲取canvas代碼,切換分支

git clone https://github.com/instructure/canvas-lms.git canvas
cd canvas
git branch --set-upstream-to origin/stable
sudo mkdir -p /opt/canvas
sudo chown -R $USER /opt/canvas
cp -rav /home/$USER/canvas/. /opt/canvas  # /opt/ 這個(gè)路徑可以隨意換到你認(rèn)為合適的位置, 這里以此為例

Step 8: 安裝ruby軟件源

sudo apt-get install software-properties-common
sudo apt-add-repository ppa:brightbox/ruby-ng
sudo apt-get update

Step 9: 安裝ruby2.4及其他依賴(lài)

sudo apt-get install ruby2.4 ruby2.4-dev zlib1g-dev libxml2-dev libsqlite3-dev postgresql libpq-dev libxmlsec1-dev curl make g++

Step 10: 安裝Node 8.x (canvas 依賴(lài)node8.x)

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

Step 11: 設(shè)置當(dāng)前賬戶(hù)為Postgres的超級(jí)用戶(hù)

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

Step 12: 安裝bundle及gems

安裝bundler

sudo gem install bundler --version 1.13.6

可以切換gems源:

gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
bundle config mirror.https://rubygems.org https://gems.ruby-china.org

安裝gems(此步驟時(shí)間較長(zhǎng))

bundle install --path vendor/bundle

Step 13: 設(shè)置Canvas默認(rèn)配置

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

配置數(shù)據(jù)庫(kù)文件,設(shè)置自己的數(shù)據(jù)庫(kù)密碼

cp ./config/database.yml.example ./config/database.yml
sudo vim ./config/database.yml
production:
 adapter: postgresql
 encoding: utf8
 database: canvas_production
 host: localhost
 username: canvas
 password: password789  # Step 5設(shè)置的密碼
 timeout: 5000
 queue:
   adapter: postgresql
   encoding: utf8
   database: canvas_queue_production
   host: localhost
   username: canvas
   password: password789 # Step 5設(shè)置的密碼
   timeout: 5000

配置SMTP郵件服務(wù)器

 cp config/outgoing_mail.yml.example config/outgoing_mail.yml

這里呢可以選用公郵例如126郵箱,下面以126郵箱為例:

首先登錄你的126郵箱 點(diǎn)擊設(shè)置

選擇 POP3/SMTP/IMAP 菜單

在此處打開(kāi) IMAP/SMTP和POP3/SMTP服務(wù)

此時(shí)會(huì)要求設(shè)置客戶(hù)端授權(quán)密碼, 該密碼講作為第三方登錄密碼,之后就可以退出126郵箱了。然后編輯config/outgoing_mail.yml

production:
 address: "smtp.126.com"  # 126的地址
 port: "25"
 user_name: "user"  # 126郵箱的賬號(hào)  不帶@126.com
 password: "password"  # 設(shè)置的客戶(hù)端授權(quán)密碼
 authentication: "login" # plain, login, or cram_md5
 domain: "126.com"
 outgoing_address: "canvas@126.com"  # 郵箱名
 default_name: "Instructure Canvas"     # 隨意設(shè)置一個(gè)顯示名

配置域名 此處配置的域名將決定在郵件中的鏈接是否能正確鏈接到網(wǎng)站上

cp config/domain.yml.example config/domain.yml

配置安全字符串 不能少于20個(gè)字符

cp config/security.yml.example config/security.yml

Step 14: 安裝js依賴(lài)

此步驟前可以生成本地一個(gè)鏡像備份(因?yàn)檫@步驟出錯(cuò)的概率比較高, 如果錯(cuò)誤了不會(huì)搞了 前面的步驟就白跑了):

退出docker后, 通過(guò)命令

sudo docker ps -a

找到剛才結(jié)束掉的容器id

然后執(zhí)行

sudo docker commit [容器id] canvas:v1.0 # canvas為設(shè)置的鏡像名 v1.0為設(shè)置的tag

之后再回到剛剛的容器中:

sudo docker start -ai [容器id]

這樣就將之前所有更改保存到了一個(gè)本地鏡像中, 名為canvas:v1.0。

接下來(lái)添加canvas用戶(hù)

sudo adduser --disabled-password --gecos canvas canvasuser

配置緩存文件

cd /opt/canvas
mkdir -p log tmp/pids public/assets public/stylesheets/compiled
touch Gemfile.lock
sudo chown -R canvasuser config/environment.rb log tmp public/assets public/stylesheets/compiled Gemfile.lock config.ru

安裝yarn 1.3.2

sudo npm install -g yarn@1.3.2

可以修改yarn的安裝源:

yarn config set registry https://registry.npm.taobao.org -g

安裝js依賴(lài) (此步驟耗時(shí)長(zhǎng))

yarn install

Step 15: 編譯assets (容易出錯(cuò))

首先檢查本地默認(rèn)系統(tǒng)編碼:

locale

如果默認(rèn)編碼不是en_US.UTF-8, 那么修改一下

sudo vim /etc/enviorment  # 重新登陸后生效

編譯assets

RAILS_ENV=production bundle exec rake canvas:compile_assets

Step 16: 初始化數(shù)據(jù)庫(kù)

RAILS_ENV=production bundle exec rake db:initial_setup  # 此步驟會(huì)設(shè)置管理員賬戶(hù), canvas剛剛部署好的時(shí)候不允許注冊(cè), 必須先用管理員賬戶(hù)登錄后,設(shè)置開(kāi)放注冊(cè)

Step 17: 修改權(quán)限

sudo chown canvasuser ./config/*.yml
sudo chown canvasuser ./config/environment.rb
sudo chmod 400 ./config/*.yml
sudo chown -R canvasuser ./log/ ./tmp/ ./public/javascripts/ ./public/assets/ ./public/stylesheets/compiled/ ./Gemfile.lock ./config.ru

Step 18: 配置Passenger 的apt源

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
sudo apt-get install -y apt-transport-https ca-certificates
sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main > /etc/apt/sources.list.d/passenger.list'
sudo apt-get update

Step 19: 安裝Passenger 及Apache (官方推薦使用)

sudo apt-get install passenger libapache2-mod-passenger apache2

Step 20: 配置passenger, apache2

sudo a2enmod rewrite
sudo a2enmod passenger
sudo a2enmod ssl
sudo a2dissite 000-default.conf
sudo vim /etc/apache2/sites-available/canvas.conf
<VirtualHost *:80>
  ServerName canvas.example.com
  ServerAlias files.canvas.example.com
  ServerAdmin youremail@example.com
  DocumentRoot /opt/canvas/public
  RewriteEngine On  # 與https相關(guān)
  RewriteCond %{HTTP:X-Forwarded-Proto} !=https # 與https相關(guān)
  RewriteCond %{REQUEST_URI} !^/health_check # 與https相關(guān)
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]   # 與https相關(guān)
  ErrorLog /var/log/apache2/canvas_errors.log
  LogLevel warn
  CustomLog /var/log/apache2/canvas_access.log combined
  SetEnv RAILS_ENV production
  <Directory /opt/canvas/public>
    #Allow from all
    AllowOverride all
    Require all granted
    Options -MultiViews
  </Directory>
</VirtualHost>
# 與https相關(guān)
<VirtualHost *:443>
  ServerName canvas.example.com
  ServerAlias files.canvas.example.com
  ServerAdmin youremail@example.com
  DocumentRoot /opt/canvas/public
  ErrorLog /var/log/apache2/canvas_errors.log
  LogLevel warn
  CustomLog /var/log/apache2/canvas_ssl_access.log combined
  SSLEngine on
  BrowserMatch "MSIE [2-6]" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
  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
  SetEnv RAILS_ENV production
  #XSendFile On
  #XSendFilePath /opt/canvas
  PassengerDefaultUser canvasuser
  PassengerFriendlyErrorPages on#open error log <Directory /opt/canvas/public>
    Options All
    AllowOverride All
    Require all granted
  </Directory>
</VirtualHost>

如果你的網(wǎng)站不支持https, 建議注釋掉跟https有關(guān)的配置

啟動(dòng)canvas站點(diǎn)

sudo a2ensite canvas.conf

本地存儲(chǔ) 如果你的文件想要存在本地 則需要設(shè)置本地存儲(chǔ)。教程暫時(shí)沒(méi)有配置s3服務(wù)器的教程。

sudo apt-get update && sudo apt-get install -y libapache2-mod-xsendfile  # 安裝xsendfile模塊
sudo a2enmod xsendfile # 啟用x-sendfile
cp ./config/environments/production.rb ./config/environments/production-local.rb
sudo vim /etc/apache2/sites-availible/canvas.conf  # 在 visual host中添加兩行:  XSendFile On  XSendFilePath /opt/canvas
sudo chmod -R 1777 tmp/
sudo chmod -R 1777 /tmp/

配置使用apache

sudo vim ./config/environments/production-local.rb
config.action_dispatch.x_sendfile_header = 'X-Sendfile' 這一行的注釋去掉

Step 21: 安裝redis服務(wù)器

sudo add-apt-repository ppa:chris-lea/redis-server
sudo apt-get update
sudo apt-get install redis-server

配置站點(diǎn)緩存文件

cp config/cache_store.yml.example config/cache_store.yml
sudo vim config/cache_store.yml
sudo chown canvasuser config/cache_store.yml
test:
    cache_store: redis_store
development:
    cache_store: redis_store
production:
    cache_store: redis_store

配置redis文件

cp config/redis.yml.example config/redis.yml
nano config/redis.yml
sudo chown canvasuser config/redis.yml
sudo chmod 400 config/redis.yml
production:
  servers:
    - redis://localhost

Step 22: 重啟apache2就可以啟動(dòng)canvas了!

sudo ln -s /opt/canvas/script/canvas_init /etc/init.d/canvas_init
sudo update-rc.d canvas_init defaults
sudo /etc/init.d/canvas_init start
sudo /etc/init.d/apache2 restart

Step 23: 添加canvas啟動(dòng)腳本

sudo vim /opt/canvas/canvas-start.sh
service postgresql start
service redis-server start
service canvas_init start  # 該服務(wù)主要負(fù)責(zé)一切延時(shí)任務(wù), 如發(fā)送郵件等
service apache2 start
tail -f /dev/null  # 保證前臺(tái)shell不退出

Step 24: 提交修改,生成鏡像, 啟動(dòng)服務(wù)!

sudo docker ps -a  # 查看剛剛的容器id
sudo docker commit [容器id] canvas:v1.1
sudo docker run -d -p 4567:80 canvas:v1.1 bash /opt/canvas/canvas-start.sh

檢查容器是否再運(yùn)行:

sudo docker ps -a

如果剛剛跑的容器還在運(yùn)行, 沒(méi)有Exited。那么,代開(kāi)瀏覽器,訪問(wèn)服務(wù)器域名 samle.com:4567, 出現(xiàn)canvas的登錄頁(yè)面則canvas部署成功!

Debug:

1. 檢查/var/log/apache2/canvas_errors.log 錯(cuò)誤日志

2. 檢查/var/log/apache2/canvas_access.log 訪問(wèn)日志

3. 檢查/var/log/apache2/error.log apache2的錯(cuò)誤日志

4. 檢查$canvas_install_path/log/production.log # canvas 日志

5. 訪問(wèn) http://domain/error_reports 查看canvas詳細(xì)錯(cuò)誤

任何問(wèn)題你可以嘗試在github的issue中搜索答案或者加入canvas交流群:46465366詢(xún)問(wèn)。

后續(xù):

1.拆分:

上面的步驟是快速搭建canvas環(huán)境的步驟,但web服務(wù),redis,postgresql,文件存儲(chǔ)都在一個(gè)docker里跑似乎有點(diǎn)太擠了。下面將redis, postgresql, 文件存儲(chǔ)全部從這一個(gè)docker容器中拆出。

第一步: 備份數(shù)據(jù)庫(kù)

pg_dump -U canvas -W -f /opt/canvas/canvas-production.sql canvas_production
pg_dump -U canvas -W -f /opt/canvas/canvas-queue.sql canvas_queue_production

第二步:關(guān)閉容器,查看容器id,將sql文件拷貝出來(lái)

sudo docker ps -a
sudo docker cp [容器id]:/opt/canvas/canvas-production.sql /home/$USER/
sudo docker cp [容器id]:/opt/canvas/canvas-queue.sql /home/$USER/

第三步:啟動(dòng)三個(gè)容器,分別代表postgresql redis 和 web服務(wù)

sudo docker run -d --name=canvaspg postgresql
sudo docker run -d --name=canvasredis redis
sudo docker run -it --name=canvas --link canvaspg:pg --link canvasredis:redis -p 4567:80 -v /home/$USER/data:/opt/canvas/tmp --privileged=true canvas:v1.1

其中 --name是指定容器名稱(chēng), --link是容器鏈接 參數(shù)為 容器名:別名 -v是目錄映射, 參數(shù)為 本地目錄:容器目錄, --privileged則是是否賦予docker容器操作映射目錄的權(quán)限。

第四步: 初始化數(shù)據(jù)庫(kù)

sudo -u postgres createuser -h pg canvas -D -S -R -P
sudo -u postgres createdb -h pg canvas_production --owner=canvas
sudo -u postgres createdb -h pg canvas_queue_production --owner=canvas

第五步:修改配置

sudo vim config/database.yml

production:
 adapter: postgresql
 encoding: utf8
 database: canvas_production
 host: pg # 將host 改為 pg
 username: canvas
 password: password789  # Step 5設(shè)置的密碼
 timeout:5000
 queue:
   adapter: postgresql
   encoding: utf8
   database: canvas_queue_production
   host: pg # 將host 改為 pg
   username: canvas
   password: password789 # Step 5設(shè)置的密碼
   timeout:5000
sudo vim config/redis.yml
  servers:    - redis://redis

第六步:退出canvas容器,查看容器id,并將備份的sql文件拷貝進(jìn)去

sudo docker ps -a
sudo docker cp /home/$USER/canvas-production.sql [容器id]:/opt/canvas
sudo docker cp /home/$USER/canvas-queue.sql [容器id]:/opt/canvas
sudo docker start -ai [容器id

第七步:恢復(fù)數(shù)據(jù)庫(kù)數(shù)據(jù)

cd /opt/canvas
psql -h pg-U canvas canvas_production
\i canvas-production.sql
\q

psql -h pg-U canvas canvas_queue_production
\i canvas-queue.sql
\q

第八步: 啟動(dòng)服務(wù)

sudo service canvas_init start
sudo service apache2 start

檢查用戶(hù)數(shù)據(jù)是否丟失,上傳的文件是否丟失,是否可以上傳刪除文件。如果上傳的文件丟失,可以通過(guò)拷貝上一個(gè)容器里面/opt/canvas/tmp目錄下的文件到/home/$USER/data下。

2. 備份與恢復(fù):

canvas中需要備份的數(shù)據(jù)總共包括一下幾點(diǎn):數(shù)據(jù)庫(kù)數(shù)據(jù), 用戶(hù)上傳的文件,canvas鏡像(不需要定期備份,需要備份的版本備份一下即可)

如果你做了后續(xù)的步驟1,那么可以如下操作:

mkdir /home/$USER/dump
sudo vim /home/$USER/dump/dump.sh
cp -r /home/$USER/data /home/$USER/dump # 備份上傳的文件
pg_dump  -h pg -U canvas -W -f /dump/canvas-production.sql canvas_production # 備份數(shù)據(jù)庫(kù)數(shù)據(jù)
pg_dump  -h pg -U canvas -W -f /dump/canvas-queue.sql  canvas_queue_production
# 壓縮
tar cvf /dump.tar dump/
cp /dump.tar /dump/
# 清理文件
rm -rf /dump/canvas-production.sql
rm -rf /dump/canvas-queue.sql
sudo docker run -it --rm --link canvaspg:pg -v /home/$USER/dump:/dump --privileged=true postgres

這樣呢 中途會(huì)詢(xún)問(wèn)canvas數(shù)據(jù)庫(kù)用戶(hù)的密碼之外, 執(zhí)行結(jié)束后再/home/$USER/dump下的dump.tar就是所有需要定期備份的文件了

如果你沒(méi)做步驟1又該怎么辦呢?

你可以先attach進(jìn)容器,然后執(zhí)行下面的命令:

pg_dump -U canvas -W -f /opt/canvas/canvas-production.sql canvas_production
pg_dump -U canvas -W -f /opt/canvas/canvas-queue.sql canvas_queue_production
cd /opt/canvas
mkdir dump
cp -r tmp/ dump/
mv canvas-production.sql dump/
mv canvas-queue.sql dump/
tar cvf dump.tar dump/

# 然后退出容器
sudo docker cp [容器id]:/opt/canvas/dump.tar ./

備份docker鏡像:

sudo docker export [容器id] > canvas-docker.tar

3. Canvas代碼升級(jí):

[下次更新補(bǔ)充]

到此這篇關(guān)于基于docker 部署 canvas-lms的文章就介紹到這了,更多相關(guān)docker 部署 canvas-lms內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 5分鐘教你實(shí)現(xiàn)用docker搭建Redis集群模式和哨兵模式

    5分鐘教你實(shí)現(xiàn)用docker搭建Redis集群模式和哨兵模式

    本文主要介紹了5分鐘實(shí)現(xiàn)用docker搭建Redis集群模式和哨兵模式,文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-09-09
  • 關(guān)于docker部署的jenkins跑git上的程序的問(wèn)題

    關(guān)于docker部署的jenkins跑git上的程序的問(wèn)題

    這篇文章主要介紹了docker部署的jenkins跑git上的程序的相關(guān)知識(shí),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-11-11
  • Docker容器實(shí)戰(zhàn)之鏡像與容器的工作原理

    Docker容器實(shí)戰(zhàn)之鏡像與容器的工作原理

    這篇文章主要介紹了Docker容器實(shí)戰(zhàn)之鏡像與容器,關(guān)于鏡像與容器的工作原理,下面文章將詳細(xì)介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下
    2022-05-05
  • 講解使用Docker搭建Java Web運(yùn)行環(huán)境

    講解使用Docker搭建Java Web運(yùn)行環(huán)境

    本篇文章詳細(xì)的介紹了使用Docker搭建Java Web運(yùn)行環(huán)境,想要學(xué)習(xí)docker的同學(xué)可以了解一下。
    2016-11-11
  • Docker 容器監(jiān)控原理及 cAdvisor的安裝與使用說(shuō)明

    Docker 容器監(jiān)控原理及 cAdvisor的安裝與使用說(shuō)明

    這篇文章主要介紹了Docker 容器監(jiān)控原理及 cAdvisor的安裝與使用說(shuō)明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-11-11
  • 如何在docker中運(yùn)行springboot項(xiàng)目過(guò)程圖解

    如何在docker中運(yùn)行springboot項(xiàng)目過(guò)程圖解

    這篇文章主要介紹了如何在docker中運(yùn)行springboot項(xiàng)目過(guò)程圖解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-06-06
  • Docker compose up -d與Docker restart的區(qū)別

    Docker compose up -d與Docker restart的區(qū)別

    本文主要介紹了Docker compose up -d與Docker restart的區(qū)別,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2023-07-07
  • Docker 教程之Docker Hub詳細(xì)介紹

    Docker 教程之Docker Hub詳細(xì)介紹

    這篇文章主要介紹了Docker 教程之Docker Hub詳細(xì)介紹的相關(guān)資料,需要的朋友可以參考下
    2016-12-12
  • docker部署zabbix_agent的方法步驟

    docker部署zabbix_agent的方法步驟

    這篇文章主要介紹了docker部署zabbix_agent的方法步驟,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-10-10
  • docker容器里安裝ssh的具體步驟

    docker容器里安裝ssh的具體步驟

    本篇文章主要介紹了docker容器里安裝ssh的具體步驟,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-05-05

最新評(píng)論