İşletim Sistemi bilgileri
Ubuntu 20.04.2 LTS
Veritabanı kurulması ve ayarları
sudo apt-get install postgresql
# db şifre set edilecek
sudo -u postgres createuser canvas --no-createdb --no-superuser --no-createrole --pwprompt
sudo -u postgres createdb canvas_production --owner=canvas
# gerekli olamayabilir.
sudo -u postgres createuser uzem
sudo -u postgres psql -c "alter user uzem with superuser" postgres
#/etc/postgresql/12/main/pg_hba.conf
# içerik olmalı
host all all 127.0.0.1/32 md5
# remote açma
host all all 10.55.16.119/24 md5
Canvas kodunun indirilmesi-dışarı çıkarılması
#wget https://github.com/instructure/canvas-lms/archive/stable.tar.gz -O ~/canvas-lms-stable.tar.gz
export CANVAS_SOURCE_VERSION="2021-03-03.17"
wget https://github.com/instructure/canvas-lms/archive/release/${CANVAS_SOURCE_VERSION}.tar.gz -O ~/canvas-${CANVAS_SOURCE_VERSION}.tar.gz
cd /var
sudo tar xf ~/canvas-${CANVAS_SOURCE_VERSION}.tar.gz
sudo mv canvas-lms-release-${CANVAS_SOURCE_VERSION} canvas
sudo chown -R uzem /var/canvas
cd /var/canvas
sudo apt install gnupg-agent
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:brightbox/ruby-ng
sudo apt-get update
sudo apt-get install ruby2.6 ruby2.6-dev zlib1g-dev libxml2-dev libsqlite3-dev postgresql libpq-dev libxmlsec1-dev curl make g++
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install nodejs
cd /var/canvas
export bundler_version="2.2.11"
sudo gem install bundler --version ${bundler_version}
bundle _${bundler_version}_ install --path vendor/bundle
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.19.1-1
yarn install
# error https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.7.0.tgz: Extracting tar content of undefined failed the file appears to be corrupt: "ENOENT: no such file or directory, chmod '/home/uzem/.cache/yarn/v6/npm-convert-source-map-1.7.0-17a2cb882d7f77d3490585e2ce6c524424a3a442-integrity/node_modules/convert-source-map/README.md'"
yarn install
#sudo add-apt-repository ppa:chris-lea/redis-server
#sudo apt-get update
sudo apt-get install redis-server
sudo cp config/cache_store.yml.example config/cache_store.yml
sudo cp config/redis.yml.example config/redis.yml
sudo nano config/redis.yml
# içerik
production:
- redis://localhost
for config in amazon_s3 database delayed_jobs domain file_store outgoing_mail security external_migration dynamic_settings logging; do cp config/$config.yml.example config/$config.yml; done
# domain ayarları yapılır.
nano config/domain.yml
# örnek içerik
production:
domain: "canvas.myhost"
# database ayarları(host, user, şifre)
nano config/database.yml
# loglama ayarları yapılır.
nano config/logging.yml
production:
logger: rails
log_level: error
# dosya kayıt yeri seçilir.
nano config/file_store.yml
production:
storage: local
path_prefix: tmp/files
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
sudo chown -R uzem config/environment.rb log tmp public/assets app/stylesheets/_brandable_variables_defaults_autogenerated.scss app/stylesheets/brandable_css_brands Gemfile.lock config.ru
# asset derlerken python ve pygments hatası için
export LC_ALL=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
sudo apt install python-pygments
ln -s /usr/bin/python3 /usr/bin/python
yarn install
RAILS_ENV=production bundle exec rake canvas:compile_assets
sudo chown -R uzem public/dist/brandable_css
export CANVAS_LMS_ADMIN_EMAIL="admin@hostname"
export CANVAS_LMS_ADMIN_PASSWORD="123456"
export CANVAS_LMS_ACCOUNT_NAME="Universite"
export CANVAS_LMS_STATS_COLLECTION="opt_out"
RAILS_ENV=production bundle exec rake db:initial_setup
# 20.04 için focal olmalı
sudo apt-get install -y dirmngr gnupg
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 focal main > /etc/apt/sources.list.d/passenger.list'
sudo apt-get update
sudo apt-get install -y passenger libnginx-mod-http-passenger
server {
listen 80;
server_name leartes;
root /var/canvas/public;
charset utf-8;
include mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/canvas.access.log;
error_log /var/log/nginx/canvas.error.log;
passenger_enabled on;
rails_env production;
}
# Statik assetlerin görülmesi için
# config/environmentsd/production.rb aşağıdaki ayar yapılmalı
# Normalde Nginx, Apache
config.public_file_server.enabled = true
# Canvas rails app çalıştırmak
RAILS_ENV=production bundle exec rails server -b 0.0.0.0 -p 3001
# Canvas rails app Nginx + Passenger çalıştırma
# yoksa bazı linkler 0.0.0.0 a gidiyor
# passenger nginx üzerinden canvas
RAILS_ENV=production passenger start
# Diğer konsolda delayed_jobs çalıştırılmalı (sis_import işleri için)
RAILS_ENV=production script/delayed_job run
# Canvas rails konsol işlemleri
RAILS_ENV=production bundle exec rails console
# Canvas veritabanı silmek ve yeniden oluşturmak
sudo -u postgres psql
postgres=# drop database canvas_production;
postgres=# \q
sudo -u postgres createdb canvas_production --owner=canvas
# Veritabanı sahiplik güncelleme
psql old_name_db
old_name_db=# REASSIGN OWNED BY old_name TO new_name;
# Veritabanı dışarı düz çıktı alma
pg_dump --data-only --inserts -U postgres canvas_production > production_pq.tmp
# Sorgunun csv çıktısını almak
Copy (Select * From foo) To '/tmp/test.csv' With CSV DELIMITER ',' HEADER;