项目源码
语言配置
Site administration
->General
->Language
->Language packs
: 安装简体中文(zh_cn)语言包Site administration
->General
->Language
->Language settings
: Default language,更改为中文- 设置管理员个人的语言偏好。点击右上角登录用户 ->
preferences
->user account
,prefered language
挂载目录
/var/www/moodledata
: Web数据目录。如需更改默认配置,要手动更改。/var/lib/postgresql/data
: 数据库目录。如需更改默认配置,要手动更改。/var/www/html
: 程序源码目录。可使用环境变量MOODLE_DOCKER_WWWROOT
更改默认值。
更改上传文件大小限制
- 更改PHP的服务器配置文件,200M改成600M
# 进入PHP容器
docker exec -it moodle-docker-webserver-1 bash
# 更新apt软件源,并安装vim文本编辑器
apt update
apt install vim
# 更改PHP的服务器配置文件,200M改成600M
vim /usr/local/etc/php/conf.d/10-docker-php-moodle.ini
# 保存文件更改,退出,重启Docker容器
./bin/moodle-docker-compose restart
/usr/local/etc/php/conf.d/10-docker-php-moodle.ini
:
; CONFIGURATION SETTINGS REQUIRED BY MOODLE
; How many GET/POST/COOKIE input variables may be accepted
; See MDL-71390 for more info. This is the recommended / required
; value to support sites having 1000 courses, activities, users....
max_input_vars = 5000
; Increase the maximum filesize to 200M, which is a more realistic figure.
upload_max_filesize = 200M
; Increase the maximum post size to accomodate the increased upload_max_filesize.
; The default value is 6MB more than the default upload_max_filesize.
post_max_size = 206M
- 进入
站点管理
->课程
->管理课程和分类
-> 编辑对应的课程,点击设置
->文件上传
,改为600M
postgres容器
# vim pgstart.sh
#!/bin/bash
docker run -it --name postgres --privileged \
-v /etc/localtime:/etc/localtime:ro \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=moodle \
-p 5432:5432 \
-v /data/postgres/data:/var/lib/postgresql/data \
-e TZ=Asia/Shanghai \
--restart always \
-d postgres:15.10
环境变量
# vim ~/.bashrc
export MOODLE_DOCKER_WEB_DATA=/home/myname/moodle_web_data
export MOODLE_DOCKER_DB_DATA=/home/myname/moodle_db_data
export MOODLE_DOCKER_WWWROOT=/home/myname/moodle
export MOODLE_DOCKER_DB=pgsql
export MOODLE_DOCKER_WEB_HOST="172.16.160.28"
export MOODLE_DOCKER_WEB_PORT="0.0.0.0:8000"
export MOODLE_DOCKER_DB_PORT="0.0.0.0:5432"
# 执行source命令,使环境变量生效: source ~/.bashrc
配置文件
关闭调试模式
vim moodle/config.php
require_once(__DIR__ . '/lib/setup.php');
// 关闭所有调试相关配置
$CFG->debug = 0; // 关闭调试模式
$CFG->debugdisplay = 0; // 禁止显示调试信息
$CFG->perfdebug = 0; // 关闭性能统计
$CFG->debugpageinfo = 0; // 关闭页面上下文信息(关键!)
$CFG->debugvalidparams = 0; // 关闭参数验证信息
邮件发送配置
方法一:通过 Moodle 管理界面配置
以管理员身份登录 Moodle
转到 "站点管理"
> "服务器"
> "电子邮件"
> "外发邮件配置"
设置以下参数:
SMTP 主机:您的邮件服务器地址(如公司内部邮件服务器)
SMTP 用户名:发件邮箱用户名(如果需要认证)
SMTP 密码:发件邮箱密码
SMTP 安全:选择适当的加密方式(如 TLS 或 SSL)
SMTP 端口:通常 587 (TLS) 或 465 (SSL)
发件邮箱:设置一个有效的发件人邮箱地址
方法二:通过配置文件设置
您可以直接编辑 Moodle 的 config.php
文件(位于 /var/www/html/config.php):
$CFG->smtphosts = 'your.smtp.server:587';
$CFG->smtpuser = 'your_username';
$CFG->smtppass = 'your_password';
$CFG->smtpsecure = 'tls';
$CFG->noreplyaddress = 'noreply@yourdomain.com';
例:vim moodle/config.php
// $CFG->smtphosts = 'mailpit:1025';
$CFG->smtphosts = 'smtp.exmail.qq.com:465';
$CFG->smtpuser = 'hr@domain.com';
$CFG->smtppass = 'xxxxxxx';
// $CFG->smtpsecure = 'tls'; 腾讯邮箱465端口,要用SSL
$CFG->smtpsecure = 'ssl';
$CFG->noreplyaddress = 'hr@domain.com';
注:
smtpuser
和noreplyaddress
要填同一个邮箱smtppass
这个密码必须和邮箱用户相匹配。没有账号要让邮箱管理员开账号。
快速启动
# Change ./moodle to your /path/to/moodle if you already have it checked out
export MOODLE_DOCKER_WWWROOT=./moodle
# Choose a db server (Currently supported: pgsql, mariadb, mysql, mssql, oracle)
export MOODLE_DOCKER_DB=pgsql
# Get Moodle code, you could select another version branch (skip this if you already got the code)
git clone -b MOODLE_403_STABLE git://git.moodle.org/moodle.git $MOODLE_DOCKER_WWWROOT
# Ensure customized config.php for the Docker containers is in place
cp config.docker-template.php $MOODLE_DOCKER_WWWROOT/config.php
# Start up containers
bin/moodle-docker-compose up -d
# Wait for DB to come up (important for oracle/mssql)
bin/moodle-docker-wait-for-db
# Work with the containers (see below)
# [..]
# Shut down and destroy containers
bin/moodle-docker-compose down