Skip to content

Deployment Overview of Moodle on Server

Prerequisites and Basic Requirements

To ensure a successful deployment, the following system requirements must be met:

  • Operating System: Debian or Ubuntu based distributions.

  • Privileges: Root or sudo access is required for package installation and configuration.

  • Ports:

  • 80 (HTTP)

  • 443 (HTTPS)

  • Dependencies: The system must have internet access to fetch PHP repositories, MariaDB repositories, and Moodle source archives.

FQDN of the final panel on the hostkey.in domain

The application is accessible via a specific subdomain template:

| Parameter | Value | | Prefix | moodle | | Domain | hostkey.in | | Full template | moodle{Server_ID_from_Invapi}.hostkey.in |

File and Directory Structure

The application uses the following directory structure for configuration and data storage:

  • Moodle Application Files: /var/www/moodle

  • Moodle Data Directory: /var/moodledata

  • Apache Configuration: /etc/apache2/sites-available/moodle.conf

  • MariaDB Configuration: /etc/mysql/mariadb.conf.d/99-moodle.cnf

  • PHP Configuration:

  • /etc/php/8.4/apache2/conf.d/99-moodle.ini

  • /etc/php/8.4/cli/conf.d/99-moodle.ini

Application installation process

The installation follows a multi-step process involving package management and manual configuration:

  1. System Preparation: The system repositories are updated, and essential base packages (curl, gnupg, unzip, tar, etc.) are installed.

  2. PHP Environment Setup:

  3. A dedicated PHP PPA is added to the repository list.

  4. PHP 8.4 and its required modules (mysql, xml, curl, zip, gd, intl, mbstring, soap, bcmath, opcache) are installed.

  5. Custom PHP configuration files are created for both Apache and CLI environments to set memory limits, upload sizes, and execution timeouts.

  6. Database Setup:

  7. The MariaDB repository is added via a setup script.

  8. MariaDB server and client packages are installed.

  9. A dedicated database named moodle is created with utf8mb4 encoding.

  10. A specific user for Moodle is created and granted necessary privileges.

  11. Moodle Application Installation:

  12. The Moodle 5.1.1 archive is downloaded from the official source.

  13. The archive is extracted to /var/www.

  14. Permissions are configured so that the web server (www-data) can access the required directories.

  15. A CLI installation script is executed to perform the initial database schema creation and admin user setup.

  16. Web Server Configuration:

  17. Apache is configured as a VirtualHost for port 80, pointing to /var/www/moodle/public.

  18. SSL certificates are obtained via Certbot using the Apache plugin.

Access Rights and Security

Security measures implemented during installation include:

  • File Permissions: Moodle application files are owned by root:www-data with restricted read access (0640 for files, 0750 for directories).

  • Data Directory Protection: The /var/moodledata directory is strictly restricted to the web server user with mode 0770.

  • Firewall: Only necessary ports (80 and 443) are required for external access.

Databases

The application uses MariaDB as its primary database engine:

Component Details
Engine MariaDB
Database Name moodle
Character Set utf8mb4
Collation utf8mb4_unicode_ci
Connection Host localhost

Custom Scripts and Additional Setup

The following automated actions are performed during the setup:

  • MariaDB Repository Setup: A script located at /usr/local/bin/mariadb_repo_setup is used to configure the official MariaDB repositories.

  • Moodle Cron Job: A system cron job is created at /etc/cron.d/moodle to run the Moodle CLI cron script every minute as the www-data user. This is essential for scheduled tasks within the application.

Application Update Instructions

To update the Moodle application, follow these steps:

  1. Download and extract the new version of Moodle into /var/www.

  2. Ensure the configuration files and directory permissions are maintained.

  3. Run the Moodle upgrade script via CLI to apply database changes.

Location of configuration files and data

  • Application Configuration: /var/www/moodle/config.php

  • Moodle Data (Files): /var/moodledata

  • Database Storage: Managed by MariaDB (standard system paths).

Available ports for connection

  • 80: HTTP access.

  • 443: Secure HTTPS access.

Starting and Stopping the application

The application relies on the Apache web server and the MariaDB database service:

  • Restarting Apache: systemctl restart apache2

  • Restarting MariaDB: systemctl restart mariadb

  • Checking Status: systemctl status apache2 or systemctl status mariadb

question_mark
Is there anything I can help you with?
question_mark
AI Assistant ×