怎样在 Ubuntu 下安装 Moodle(魔灯)

这是一篇关于如何在 Ubuntu 16.04 上安装 Moodle (“魔灯”)的逐步指南。Moodle (模块化面向对象动态学习环境Modular-object-oriented dynamic learning environment的缩写)是一种自由而开源的学习管理系统,为教师、学生和管理员提供个性化的学习环境。Moodle 由 Moodle 项目创建,由 Moodle 总部统一领导和协调。

Moodle 有很多非常实用的功能,比如:

  • 现代和易于使用的界面
  • 个性化仪表盘
  • 协作工具和活动
  • 一体式日历
  • 简单的文本编辑器
  • 进度跟踪
  • 公告
  • 不胜枚举…

在本教程中,我们将指导您在 Ubuntu 16.04 VPS 上利用 Apache web 服务器、MySQL 和 PHP 7 安装最新版本的 Moodle。(LCTT 译注:在 Ubuntu 的后继版本上的安装也类似。)

 

1、 通过 SSH 登录

首先,利用 root 用户通过 SSH 登录到 Ubuntu 16.04 VPS:

  1. <span class="kwd">ssh</span><span class="pln"> root@IP_Address </span><span class="pun">-</span><span class="pln">p </span><span class="typ">Port_number</span>

 

2、 更新操作系统软件包

运行以下命令更新系统软件包并安装一些依赖软件:

  1. <span class="kwd">apt-get</span><span class="pln"> update </span><span class="pun">&&</span><span class="kwd">apt-get</span><span class="pln"> upgrade</span>
  2. <span class="kwd">apt-get</span><span class="pln"> install </span><span class="kwd">git</span><span class="pun">-</span><span class="pln">core graphviz aspell</span>

 

3、 安装 Apache Web 服务器

利用下面命令,从 Ubuntu 软件仓库安装 Apache Web 服务器:

  1. <span class="kwd">apt-get</span><span class="pln"> install apache2</span>

 

4、 启动 Apache Web 服务器

一旦安装完毕,启动 Apache 并使它能够在系统启动时自动启动,利用下面命令:

  1. <span class="kwd">systemctl</span><span class="pln"> enable apache2</span>

 

5、 安装 PHP 7

接下来,我们将安装 PHP 7 和 Moodle 所需的一些额外的 PHP 模块,命令是:

  1. <span class="kwd">apt-get</span><span class="pln"> install php7</span><span class="pun">.</span><span class="lit">0</span><span class="pln"> libapache2</span><span class="pun">-</span><span class="pln">mod</span><span class="pun">-</span><span class="pln">php7</span><span class="pun">.</span><span class="lit">0</span><span class="pln"> php7</span><span class="pun">.</span><span class="lit">0</span><span class="pun">-</span><span class="pln">pspell php7</span><span class="pun">.</span><span class="lit">0</span><span class="pun">-</span><span class="pln">curl php7</span><span class="pun">.</span><span class="lit">0</span><span class="pun">-</span><span class="pln">gd php7</span><span class="pun">.</span><span class="lit">0</span><span class="pun">-</span><span class="pln">intl php7</span><span class="pun">.</span><span class="lit">0</span><span class="pun">-</span><span class="pln">mysql php7</span><span class="pun">.</span><span class="lit">0</span><span class="pun">-</span><span class="pln">xml php7</span><span class="pun">.</span><span class="lit">0</span><span class="pun">-</span><span class="pln">xmlrpc php7</span><span class="pun">.</span><span class="lit">0</span><span class="pun">-</span><span class="pln">ldap php7</span><span class="pun">.</span><span class="lit">0</span><span class="pun">-</span><span class="pln">zip</span>

 

6、 安装和配置 MySQL 数据库服务器

Moodle 将大部分数据存储在数据库中,所以我们将利用以下命令安装 MySQL 数据库服务器:

  1. <span class="kwd">apt-get</span><span class="pln"> install mysql</span><span class="pun">-</span><span class="pln">client mysql</span><span class="pun">-</span><span class="pln">server</span>

安装完成后,运行 mysql_secure_installation 脚本配置 MySQL 的 root 密码以确保 MySQL 安全。

root 用户登录到 MySQL 服务器,并为 Moodle 创建一个数据库以及能访问它的用户,以下是具体操作指令:

  1. <span class="pln">mysql </span><span class="pun">-</span><span class="pln">u root </span><span class="pun">-</span><span class="pln">p</span>
  2. <span class="pln">mysql</span><span class="pun">></span><span class="pln"> CREATE DATABASE moodle</span><span class="pun">;</span>
  3. <span class="pln">mysql</span><span class="pun">></span><span class="pln"> GRANT ALL PRIVILEGES ON moodle</span><span class="pun">.*</span><span class="pln"> TO </span><span class="str">'moodleuser'</span><span class="pun">@</span><span class="str">'localhost'</span><span class="pln"> IDENTIFIED BY </span><span class="str">'PASSWORD'</span><span class="pun">;</span>
  4. <span class="pln">mysql</span><span class="pun">></span><span class="pln"> FLUSH PRIVILEGES</span><span class="pun">;</span>
  5. <span class="pln">mysql</span><span class="pun">></span><span class="pln"> \q</span>

一定要记得将上述 PASSWORD 替换成一个安全性强的密码。

 

7、 从 GitHub 仓库获取 Moodle

接下来,切换当前工作目录,并从 GitHub 官方仓库中复制 Moodle:

  1. <span class="kwd">cd</span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">html</span><span class="pun">/</span>
  2. <span class="kwd">git</span><span class="kwd">clone</span><span class="pln"> https</span><span class="pun">:</span><span class="com">//github.com/moodle/moodle.git</span>

切换到 moodle 目录,检查所有可用的分支:

  1. <span class="kwd">cd</span><span class="pln"> moodle</span><span class="pun">/</span>
  2. <span class="kwd">git</span><span class="pln"> branch </span><span class="pun">-</span><span class="pln">a</span>

选择最新稳定版本(当前是 MOODLE_34_STABLE ),运行以下命令告诉 git 哪个分支可以跟踪或使用:

  1. <span class="kwd">git</span><span class="pln"> branch </span><span class="pun">--</span><span class="pln">track MOODLE_34_STABLE origin</span><span class="pun">/</span><span class="pln">MOODLE_34_STABLE</span>

并切换至这个特定版本:

  1. <span class="kwd">git</span><span class="pln"> checkout MOODLE_34_STABLE</span>
  2. <span class="typ">Switched</span><span class="pln"> to branch </span><span class="str">'MOODLE_34_STABLE'</span>
  3. <span class="typ">Your</span><span class="pln"> branch </span><span class="kwd">is</span><span class="pln"> up</span><span class="pun">-</span><span class="pln">to</span><span class="pun">-</span><span class="kwd">date</span><span class="kwd">with</span><span class="str">'origin/MOODLE_34_STABLE'</span><span class="pun">.</span>

为存储 Moodle 数据创建目录:

  1. <span class="kwd">mkdir</span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">moodledata</span>

正确设置其所有权和访问权限:

  1. <span class="kwd">chown</span><span class="pun">-</span><span class="pln">R www</span><span class="pun">-</span><span class="pln">data</span><span class="pun">:</span><span class="pln">www</span><span class="pun">-</span><span class="pln">data </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">html</span><span class="pun">/</span><span class="pln">moodle</span>
  2. <span class="kwd">chown</span><span class="pln"> www</span><span class="pun">-</span><span class="pln">data</span><span class="pun">:</span><span class="pln">www</span><span class="pun">-</span><span class="pln">data </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">moodledata</span>

 

8、 配置 Apache Web 服务器

使用以下内容为您的域名创建 Apache 虚拟主机:

  1. <span class="kwd">nano</span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">apache2</span><span class="pun">/</span><span class="pln">sites</span><span class="pun">-</span><span class="pln">available</span><span class="pun">/</span><span class="pln">yourdomain</span><span class="pun">.</span><span class="pln">com</span><span class="pun">.</span><span class="pln">conf</span>
  2. <span class="typ">ServerAdmin</span><span class="pln"> admin@yourdomain</span><span class="pun">.</span><span class="pln">com</span>
  3. <span class="typ">DocumentRoot</span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">html</span><span class="pun">/</span><span class="pln">moodle</span>
  4. <span class="typ">ServerName</span><span class="pln"> yourdomain</span><span class="pun">.</span><span class="pln">com</span>
  5. <span class="typ">ServerAlias</span><span class="pln"> www</span><span class="pun">.</span><span class="pln">yourdomain</span><span class="pun">.</span><span class="pln">com</span>
  6. <span class="typ">Options</span><span class="typ">Indexes</span><span class="typ">FollowSymLinks</span><span class="typ">MultiViews</span>
  7. <span class="typ">AllowOverride</span><span class="typ">All</span>
  8. <span class="typ">Order</span><span class="pln"> allow</span><span class="pun">,</span><span class="pln">deny</span>
  9. <span class="pln">allow </span><span class="kwd">from</span><span class="pln"> all</span>
  10. <span class="typ">ErrorLog</span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">log</span><span class="pun">/</span><span class="pln">httpd</span><span class="pun">/</span><span class="pln">yourdomain</span><span class="pun">.</span><span class="pln">com</span><span class="pun">-</span><span class="pln">error_log</span>
  11. <span class="typ">CustomLog</span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">log</span><span class="pun">/</span><span class="pln">httpd</span><span class="pun">/</span><span class="pln">yourdomain</span><span class="pun">.</span><span class="pln">com</span><span class="pun">-</span><span class="pln">access_log common</span>

保存文件并启用虚拟主机:

  1. <span class="pln">a2ensite yourdomain</span><span class="pun">.</span><span class="pln">com</span>
  2. <span class="typ">Enabling</span><span class="pln"> site yourdomain</span><span class="pun">.</span><span class="pln">com</span><span class="pun">.</span>
  3. <span class="typ">To</span><span class="pln"> activate the </span><span class="kwd">new</span><span class="pln"> configuration</span><span class="pun">,</span><span class="pln"> you need to run</span><span class="pun">:</span>
  4. <span class="pln">service apache2 reload</span>

最后,重启 Apache Web 服务器,以使配置生效:

  1. <span class="pln">service apache2 reload</span>

 

9、 接下来按照提示完成安装

现在,点击 “http://yourdomain.com”(LCTT 译注:在浏览器的地址栏里输入以上域名以访问 Apache WEB 服务器),按照提示完成 Moodle 的安装。有关如何配置和使用 Moodle 的更多信息,您可以查看其官方文档

如果您使用我们的优化的 Moodle 托管主机服务,您不必在 Ubuntu 16.04 上安装 Moodle,在这种情况下,您只需要求我们的专业 Linux 系统管理员在 Ubuntu 16.04 上安装和配置最新版本的 Moodle。他们将提供 24×7 及时响应的服务。(LCTT 译注:这是原文作者——一个主机托管商的广告~)

PS. 如果你喜欢这篇关于如何在 Ubuntu 16.04 上安装 Moodle 的帖子,请在社交网络上与你的朋友分享,或者留下你的回复。谢谢。


via: https://www.rosehosting.com/blog/how-to-install-moodle-on-ubuntu-16-04/

作者:RoseHosting 译者:stevenzdg988 校对:wxy

本文由 LCTT 原创编译,Linux中国 荣誉推出

相关推荐