Moodle

来自 阿尔派 Linux

在 阿尔派 Linux 上安装 Moodle

Moodle 是最著名的开源学习管理系统之一。以下步骤已在 Alpine Linux 3.21.3 的全新安装上进行过测试。

1. 安装 Apache2 服务器

 # apk add apache2
 # rc-service apache2 start  # Start the service
 # rc-update add apache2    # Enable auto-start on boot
 Configuration file location: /etc/apache2/httpd.conf
 Web root directory: /var/www/localhost/htdocs
 Log file location: /var/log/apache2

通过打开客户端浏览器并检查“It works!”成功页面来验证安装。


2. 安装 PHP 并配置 Apache2 以支持 PHP

 # apk add php php-apache2
 The current default installed PHP version is 8.3. The configuration files to enable PHP support in Apache2 are automatically generated and installed, which is great!
 It is recommended to add index.php to the appropriate location in the Apache2 configuration file for convenience in later steps.
 At least one parameter in the default PHP configuration file needs to be adjusted; otherwise, the installation will fail:
 # vi /etc/php/php83/php.ini
 Locate the max_input_vars parameter, remove the comment symbol (;), and change the default value from 1000 to 5000.
 After making the change, restart Apache2 to apply the PHP configuration:
 # rc-service apache2 restart
 Create a test file test.php in the web root directory:
                <?php phpinfo(); ?>
 Then, enter the following URL in the client browser:
              http://your-ip/test.php
 You should see a detailed page displaying various PHP parameters.


3. 安装 MariaDB 数据库服务器

 #apk add mariadb mariadb-client
 Prepare the necessary directories and permissions:
 # mkdir -p /var/lib/mysql
 # chown mysql:mysql /var/lib/mysql
 # /etc/init.d/mariadb setup
 Start the MariaDB service and enable auto-start on boot:
 # rc-service mariadb start
 # rc-update add mariadb
 It is also recommended to perform security configurations and set a password for the database superuser:
 # mysql_secure_installation


4. 安装所需的 PHP 模块

 Moodle requires many additional PHP modules. Install them all at once:
 # apk add php-ctype php-curl php-dom php-exif php-fileinfo php-gd php-iconv php-intl php-mbstring php-mysqli php-opcache php-session php-simplexml php-soap php-sodium php-tokenizer php-xml php-xmlreader php-zip
 If any modules are missing, Moodle will detect them during the client-side installation, and you can install them later.
 Don’t forget to restart Apache2 to apply the changes:
 # rc-service apache2 restart


5. 安装 Moodle

 # cd /var/www/localhost
 # chown apache:apache moodledata
 # cd /var/www/localhost/htdocs
 # wget https://packaging.moodle.org/stable405/moodle-4.5.2.tgz
 (The latest version is 4.5.2, but you can download a newer version from the official website: www.moodle.org)
 # tar zxvf moodle-4.5.2.tgz
 The remaining installation steps must be completed in the client browser:
              http://your-ip/moodle
 If the previous steps were completed without errors, the client-side installation should proceed smoothly. Follow the on-screen prompts and click "Next" as needed. During the process, a Moodle configuration file (config.php) will be generated, which needs to be manually copied to the Moodle root directory. (Alternatively, you can set the Moodle directory to a+w permissions to avoid this step, but this reduces security.)
 This guide should help you successfully install Moodle on Alpine Linux!