Moodle
Installing Moodle on Alpine Linux
Moodle is one of the most well-known open-source learning management systems. The following steps have been tested on a fresh installation of Alpine Linux 3.21.3.
1. Install Apache2 Server
# 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
Verify the installation by opening the client browser and checking for the "It works!" success page.
2. Install PHP and Configure Apache2 to Support 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. Install MariaDB Database Server
#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. Install Required PHP Modules
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. Install 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!