docker安裝moodle線上學習初體驗

docker搜尋一下, 找到 bitnami 製作的moodle images , 照著做滿簡單就能架站


1. 下載docker compose yaml檔案

curl -sSL https://raw.githubusercontent.com/bitnami/bitnami-docker-moodle/master/docker-compose.yml > docker-compose.yml

2. 修改yml如下

version: '2'
 services:
   mariadb:
     image: 'docker.io/bitnami/mariadb:latest'
     environment:
       - ALLOW_EMPTY_PASSWORD=yes
       - MARIADB_USER=bn_moodle
       - MARIADB_DATABASE=bitnami_moodle
       - MARIADB_CHARACTER_SET=utf8mb4
       - MARIADB_COLLATE=utf8mb4_unicode_ci
     volumes:
       - 'mariadb_data:/bitnami/mariadb'
   moodle:
     image: 'docker.io/bitnami/moodle:latest'
     ports:
       - '8088:8080'
       - '8445:8443'
     environment:
       - MOODLE_DATABASE_HOST=mariadb
       - MOODLE_DATABASE_PORT_NUMBER=3306
       - MOODLE_DATABASE_USER=bn_moodle
       - MOODLE_DATABASE_NAME=bitnami_moodle
       - ALLOW_EMPTY_PASSWORD=yes
     volumes:
       - 'moodle_data:/bitnami/moodle'
       - 'moodledata_data:/bitnami/moodledata'
     depends_on:
       - mariadb
     hostname:'<主機名稱>'
 volumes:
   mariadb_data:
     driver: local
   moodle_data:
     driver: local
   moodledata_data:
     driver: local

3. 這個moodle container 內部預設的http port 8080 , https port 8443, 我改成 80888445

docker-compose up -d

4. 瀏覽器輸入 https://ip:8445 登入, 預設帳號 user , 密碼 bitnami

5. 設定docker本體主機上面的let's enpcrypt後, 進行httpd apache 與container對應工作

<VirtualHost *:443>
  ServerName 主機名稱
  ErrorLog /var/log/httpd/ssl_error_log
  TransferLog /var/log/httpd/ssl_access_log
  SSLEngine On
  SSLCertificateFile /etc/letsencrypt/live/<主機名稱>/cert.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/<主機名稱>/privkey.pem
  SSLCACertificateFile /etc/letsencrypt/live/<主機名稱>/fullchain.pem
  SSLProxyEngine On
  ProxyRequests Off
  ProxyPreserveHost On
  RequestHeader set X-Forwarded-Proto "https"
  ProxyPass / http://localhost:8088/
  ProxyPassReverse / http://localhost:8088/
  <Location />
    Order allow,deny
    Allow from all
  </Location>
</VirtualHost>   

 

6. 若需要發email , 除了設定server ip 帳號密碼外, 還需要進入container , 安裝sendmail 這支程式 (2021/03/02)
另外需要進入container, 手動新增crontab規則(2021/03/04)

crontab -u www-data -e
####
*/15 * * * * /opt/bitnami/php/bin/php /bitnami/moodle/admin/cli/cron.php >/dev/null
#請確認php路徑,與moodle安裝路徑是否正確

發表迴響