您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

如何在 Moodle 迁移后跟进How to follow up after a Moodle migration

迁移后的任务Post-migration tasks

迁移 Moodle 后,需要注意一些迁移后任务,以完成配置。After migrating Moodle, you need to take care of some post-migration tasks to complete your configuration. 这些任务包括:These tasks include:

  • 正在更新虚拟机规模集实例中的日志路径。Updating log paths in virtual machine scale set instances.
  • 正在重启虚拟机规模集实例中的服务器。Restarting servers in virtual machine scale set instances.
  • 更新证书。Updating certificates.
  • 正在更新证书位置。Updating certificate locations.
  • 正在更新 HTML 本地副本。Updating the HTML local copy.
  • 正在重启 PHP 和 NGINX 服务器。Restarting the PHP and NGINX servers.
  • 将 DNS 名称映射到 Azure 负载均衡器 IP 地址。Mapping the DNS name to the Azure Load Balancer IP address.

控制器虚拟机规模集Controller virtual machine scale set

执行以下步骤以完成配置虚拟机规模集。Take the following steps to finish configuring your virtual machine scale set. 需要使用专用 IP 地址通过 SSH 连接到虚拟机规模集实例,如 访问虚拟机规模集中所述。You will need to SSH to your virtual machine scale set instance by using the private IP address, as described in Access the virtual machine scale set.

更新日志路径Update log paths

本地环境和 Azure 可能会将日志文件存储在不同的位置。Your on-premises environment and Azure might store log files in different locations. 例如,你可能需要更新这些日志路径:For example, you might need to update these log paths:

  • /var/log/syslogs/moodle/access.log
  • /var/log/syslogs/moodle/error.log

按照以下步骤更新日志文件位置:Follow these steps to update the log file locations:

  1. 输入以下命令打开配置文件:Enter this command to open the configuration file:

    nano /etc/nginx/nginx.conf
    
  2. 查找 access_logerror_log ,并更新日志路径。Find access_log and error_log, and update the log paths.

  3. 按 Ctrl + O 保存更改,并按 Ctrl + X 关闭文件。Press Ctrl+O to save the changes and Ctrl+X to close the file.

重新启动服务器Restart servers

输入以下命令以重新启动 nginxphp-fpm 服务器:Enter these commands to restart the nginx and php-fpm servers:

sudo systemctl restart nginx
sudo systemctl restart php<php version>-fpm

控制器虚拟机Controller virtual machine

执行以下步骤以完成控制器虚拟机配置。Take these steps to complete the controller virtual machine configuration.

更新安全证书Update security certificates

  1. 登录到控制器虚拟机。Sign in to the controller virtual machine. 你可以在文件夹中找到 Moodle 应用程序的证书 /moodle/certsYou can find the certificates for your Moodle application in the /moodle/certs folder.

  2. .crt.key 文件复制到 /moodle/certs/Copy the .crt and .key files to /moodle/certs/. 将文件名分别更改为 nginx.crtnginx.key ,以便已配置的 NGINX 服务器识别它们。Change the file names to nginx.crt and nginx.key, respectively, so that the configured NGINX servers recognize them. 如果本地环境支持 SCP 实用工具或类似于 WinSCP 的工具,则可以使用这些工具将这些文件复制到控制器虚拟机。If your local environment supports the SCP utility or a tool like WinSCP, you can use these tools to copy these files to the controller virtual machine. 否则,请使用以下命令:Otherwise, use these commands:

    cd /<path to certs location>
    mv /<path to certs location>/*.key /moodle/certs/nginx.key
    mv /<path to certs location>/*.crt /moodle/certs/nginx.crt
    

    作为复制文件的替代方法,请使用以下命令生成自签名证书:As an alternative to copying the files, use these commands to generate a self-signed certificate:

    openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
    -keyout /moodle/certs/nginx.key \
    -out /moodle/certs/nginx.crt \
    -subj "/C=US/ST=WA/L=Redmond/O=IT/CN=mydomain.com"
    

    只能使用自签名证书进行测试。You can only use a self-signed certificate for testing.

  3. 建议将证书文件作为 www-data:www-data 所有者,并对所有者只读。It's recommended that the certificate files are owned by www-data:www-data and are read-only to the owner. 输入以下命令进行这些更改:Enter these commands to make those changes:

    chown www-data:www-data /moodle/certs/nginx.*
    chmod 400 /moodle/certs/nginx.*
    
  4. 通过执行以下步骤更新证书位置:Update the certificate location by taking these steps:

    1. 输入以下命令打开配置文件:Enter this command to open the configuration file:

      nano /etc/nginx/sites-enabled/*.conf
      
    2. ssl_certificate在文件中查找。Find ssl_certificate in the file.

    3. 将证书的路径替换为以下值:Replace the certificate's paths with these values:

      /moodle/certs/moodle/certs/nginx.crt;
      /moodle/certs/nginx.key;
      
    4. 按 Ctrl + O 保存更改,并按 Ctrl + X 关闭文件。Press Ctrl+O to save your changes and Ctrl+X to close the file.

更新本地 HTML 副本Update local HTML copy

Moodle HTML 网站内容的本地副本在 /moodle/html/moodle 此文件夹中的虚拟机规模集中创建: /var/www/html/moodleThe local copy of the Moodle HTML site content, /moodle/html/moodle, is created in the virtual machine scale set in this folder: /var/www/html/moodle. 仅当时间戳更改时,本地副本才会更新。The local copy is updated only when the time stamp changes. 在控制器虚拟机中输入此命令以更新时间戳:Enter this command in the controller virtual machine to update the time stamp:

sudo -s
/usr/local/bin/update_last_modified_time.moodle_on_azure.sh

最后修改的时间戳文件 /moodle/html/moodle/last_modified_time.moodle_on_azure 包含一个脚本。The last-modified time stamp file, /moodle/html/moodle/last_modified_time.moodle_on_azure, contains a script. 每次运行脚本时,将 /moodle/html/moodle 在本地副本中更新目录内容 /var/www/htmlEvery time that the script runs, the /moodle/html/moodle directory content is updated in the local copy, /var/www/html.

重新启动服务器Restart servers

输入以下命令以重新启动 nginxphp-fpm 服务器:Enter these commands to restart the nginx and php-fpm servers:

sudo systemctl restart nginx
sudo systemctl restart php<php version>-fpm

将 DNS 名称映射到 Azure 负载均衡器 IP 地址Map the DNS name to the Azure Load Balancer IP address

按照托管提供程序级别的以下步骤将 DNS 名称映射到 Azure 负载均衡器 IP:Follow these steps at the hosting-provider level to map the DNS name to the Azure Load Balancer IP:

  1. 在控制器虚拟机中输入以下命令,在 Moodle 网站上关闭维护模式:Enter the following command in the controller virtual machine to turn off maintenance mode on the Moodle website:

    sudo /usr/bin/php admin/cli/maintenance.php --disable
    
  2. 输入以下命令以检查 Moodle 站点的状态:Enter this command to check the status of the Moodle site:

    sudo /usr/bin/php admin/cli/maintenance.php
    
  3. 若要查看迁移的 Moodle 网页,请访问 DNS 名称。Go to the DNS name to see the migrated Moodle web page.

常见问题和疑难解答Frequently asked questions and troubleshooting

当你对 Moodle 迁移有疑问时,请参考以下信息。Refer to the following information when you have questions about your Moodle migration. 这些日志文件还可以帮助解决问题:These log files can also help you troubleshoot problems:

  • Syslog 文件:Syslog files:

    • 每当用户进入你的网页时,系统都会生成错误日志或访问日志。Whenever a user goes to your webpage, the system generates either an error log or an access log.
    • 可以在此文件夹中找到它们: /var/log/nginx/You can find them in this folder: /var/log/nginx/.
  • Cron 日志文件:Cron log file:

    • Cron 作业运行时,会更新日志文件的本地副本。When a cron job runs, it updates the local copy of the log file.
    • 可在此文件夹中找到该文件: /var/log/sitelogs/moodle/cron.logYou can find the file in this folder: /var/log/sitelogs/moodle/cron.log.

数据库连接失败Database connection failure

对于 数据库连接失败无法连接到指定数据库 的错误,以下是一些可能的原因和解决方法:For errors like database connection failed or could not connect to the database you specified, here are some potential reasons and solutions:

  • 你的数据库服务器未安装或未运行。Your database server isn't installed or running. 若要在 MySQL 中检查此条件,请输入以下命令:To check for this condition in MySQL, enter the following command:

    $telnet database_host_name 3306
    

    如果数据库正在运行,则应收到包含 MySQL 服务器版本号的响应。If your database is running, you should get a response that includes the version number of the MySQL server.

  • 主机地址配置不正确。The host address is configured incorrectly. 如果在不同端口上运行两个 Moodle 实例,请在设置中使用主机的 IP 地址,而不是 localhost $CFG->dbhostIf you're running two instances of Moodle on different ports, use the IP address of the host, not localhost, in the $CFG->dbhost setting. 例如,使用:For example, use:

    $CFG->dbhost = 127.0.0.1:3308

  • 尚未创建 Moodle 数据库。You haven't created a Moodle database. 或者您没有为访问数据库分配足够的权限。Or you haven't assigned adequate permissions for accessing the database. 检查数据库以及所授予的权限。Check the database and the permissions that you granted.

  • Moodle 数据库设置不正确。The Moodle database settings aren't correct. 例如,Moodle 配置文件中的数据库名称、用户名或密码 config.php 不正确。For instance, the database name, username, or password in your Moodle configuration file, config.php, isn't correct. 请确保你的 MySQL 用户名和密码不包含撇号或非字母数字字符。Make sure your MySQL username and password don't contain apostrophes or non-alphanumeric characters.

内部服务器错误Internal server error

此错误有几个可能的原因: 500:内部服务器错误There are several possible causes for this error: 500: Internal Server Error. 首先检查 web 服务器错误日志,其中应该包含详细说明。Start by checking your web server error log, which should contain a detailed explanation. 下面是一些可能的原因:Here are some possibilities:

  • 或文件中存在语法错误 .htaccess httpd.confThere's a syntax error in your .htaccess or httpd.conf file. 指令的正确语法因所使用的文件而异。The correct syntax for directives differs depending on which file you're using. 使用以下命令测试 NGINX 文件中的配置错误:Use the following command to test for configuration errors in your NGINX files:

    `nginx -t`
    
  • Web 服务器在你自己的用户名下运行,并且访问权限不正确。The web server runs under your own user name, and the access permissions are incorrect. 在这种情况下,所有文件需要的最大权限级别为755。In this case, all files need a maximum permission level of 755. 检查是否为控制面板中的 Moodle 目录设置了此级别。Check that this level is set for your Moodle directory in your control panel. 如果有权访问 shell,请使用此命令设置级别:Or use this command to set the level if you have access to the shell:

    chmod -R 755 moodle
    

内存限制错误Memory limit error

出现 403:禁止 错误时,php memory_limit 值对于 php 脚本而言不够大。When a 403: Forbidden error occurs, the PHP memory_limit value isn't large enough for the PHP script. memory_limit该值为允许的内存大小。The memory_limit value is the allowed memory size. memory_limit将 PHP 值增大少量,直到消息消失。Increase the PHP memory_limit value by small amounts until the message disappears. 使用以下方法之一:Use one of these methods:

  • 对于托管安装,要求主机支持如何增加值。For a hosted installation, ask your host's support how to increase the value. 许多环境使用 .htaccess 文件。Many environments use .htaccess files. 如果安装执行此操作,请将以下行添加到 .htaccess 文件中:If your installation does, add the following line to your .htaccess file:

    php_value memory_limit <value>M
    

    例如,要将该值增加到 40 mb,请输入:For example, to increase the value to 40 megabytes, enter:

    php_value memory_limit 40M

    如果 .htaccess 文件不存在,请在带有该行的 Moodle 目录中创建一个。If no .htaccess file exists, create one in the Moodle directory with that line.

  • 如果你拥有自己的具有 shell 访问权限的服务器,请编辑 php.ini 文件。If you have your own server with shell access, edit your php.ini file. 然后重新启动 web 服务器以应用在中所做的更改 php.iniThen restart your web server to apply the changes that you made in php.ini. 若要确保正确更新了值,请输入以下命令:To make sure you've updated the value correctly, enter this command:

    `phpinfo`
    

    的输出 phpinfo 应包含类似于下面的行:The output from phpinfo should contain a line similar to this one:

    memory_limit <value>M
    

    例如,它可能包含以下行:For example, it might contain this line:

    memory_limit 40M

增加值的替代方法 memory_limit 是通过输入以下命令来关闭内存限制:An alternative to increasing the memory_limit value is to turn off the memory limit by entering this command:

memory_limit 0

登录错误Sign-in errors

有时你无法登录,或者你会看到以下消息之一:Sometimes you can't sign in, or you see one of these messages:

  • Your session has timed out. Please log in again.

  • A server error that affects your login session was detected. Please log in again or restart your browser.

身份验证方法可能存在问题,尤其是在使用 LDAP 这样的外部方法对用户进行身份验证时。There might be a problem with your authentication method, especially if you use an external method like LDAP to authenticate users. 尝试登录到其他手动帐户,如主管理员帐户。Try to sign in to another manual account, such as your main admin account. 如果无法登录,请检查身份验证。If you can't sign in, check your authentication. 如果可以登录到其他帐户,以下是 Moodle 登录问题的可能原因和解决方案:If you can sign in to the other account, here are possible reasons and solutions for the Moodle sign-in problem:

  • 硬盘可能已满。Your hard disk might be full. 在这种情况下,Moodle 无法创建新的会话,并且用户无法登录。In this situation, Moodle can't create new sessions, and users can't sign in. 检查硬盘是否已满,你的服务器是否位于共享主机上,并且你没有达到磁盘空间配额。Check that your hard disk isn't full, that your server is on shared hosting, and that you haven't reached your disk space quota.

  • Web 服务器无法写入 sessions 子目录。The web server can't write to the sessions subdirectory. 请仔细检查您 moodledata 所在地区的权限。Carefully check the permissions in your moodledata area.

错误Fatal errors

如果看到此错误,则 Moodle 和 moodledata 权限可能不正确: fatal error: $cfg->dataroot is not writable. The admin has to fix directory permissions! Exiting.The Moodle and moodledata permissions might be incorrect if you see this error: fatal error: $cfg->dataroot is not writable. The admin has to fix directory permissions! Exiting.

请检查这些权限是否为 www-data:www-dataCheck that these permissions are www-data:www-data only. 如果权限在不同级别,请使用以下命令更改组和所有权权限:If the permissions are at a different level, use this command to change the group and ownership permissions:

sudo chown -R /moodle/moodledata

顶级课程错误Top-level course errors

如果在安装 Moodle 后找不到顶级课程,则说明安装可能未完成。If you can't find a top-level course right after you install Moodle, the installation probably didn't finish. 在完整安装结束之前,Moodle 会要求你提供管理员配置文件,并提示你为网站命名。Right before the end of a complete installation, Moodle asks you for the administrator profile and prompts you to name the site. 如果这些步骤丢失,请检查日志中是否有错误。If these steps were missing, check your logs for errors. 然后重新启动数据库。Then restart the database. 如果你使用的是基于 web 的安装程序,请使用命令行再次安装 Moodle。If you used the web-based installer, install Moodle again by using the command line.

如果在登录后无法在 Moodle 中自由导航,则表明 URL 配置可能不正确。If you can't navigate freely in Moodle after you sign in, your URL configuration might be incorrect. 请确保设置中的 URL 与 $CFG->wwwroot 用于访问站点的 URL 相同。Make sure that the URL in your $CFG->wwwroot setting is the same one that you use to access the site.

文件上传错误File upload errors

如果上传文件时出现 "找 不到文件 " 错误,则表明 web 服务器可能未启用斜杠参数。If you see a File not found error when uploading a file, your web server might not have turned on slash arguments.

  • 如果 web 服务器支持斜杠参数,请将其打开。If your web server supports slash arguments, turn them on.

  • 如果 web 服务器不支持斜杠参数,请清除 管理 站点管理 > > 服务器 > HTTP 中的 "使用斜杠参数" 复选框,以在 Moodle 中将其关闭。If your web server doesn't support slash arguments, turn them off in Moodle by clearing the Use slash arguments check box in Administration > Site administration > Server > HTTP. 你可能会看到此消息。You may see this message.

    警告

    禁用斜杠参数将导致 SCORM 包不起作用,并且会显示斜杠参数警告!Disabling slash arguments will result in SCORM packages not working and slash arguments warnings being displayed!

维护模式错误Maintenance mode errors

当 Moodle 处于维护模式时,如果你尝试离开该模式,则有时会看到此消息: 此站点正在进行维护,当前不可用When Moodle is in maintenance mode and you try to leave that mode, sometimes you see this message: This site is undergoing maintenance and is currently unavailable. maintenance.html Moodle 在处于 moodledata 维护模式时,在文件夹中创建的文件出现问题时,就会出现这种情况。This situation comes up when there's a problem with the maintenance.html file that Moodle creates in the moodledata folder when it goes into maintenance mode. 在这种情况下,请执行以下步骤:In this case, take these steps:

  • 检查 web 服务器用户在目录中是否具有写入权限 moodledataCheck that the web server user has write permissions in the moodledata directory.
  • 手动删除 maintenance.html 文件。Manually delete the maintenance.html file.

后续步骤Next steps