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:
-
System Preparation: The system repositories are updated, and essential base packages (curl, gnupg, unzip, tar, etc.) are installed.
-
PHP Environment Setup:
-
A dedicated PHP PPA is added to the repository list.
-
PHP 8.4 and its required modules (
mysql,xml,curl,zip,gd,intl,mbstring,soap,bcmath,opcache) are installed. -
Custom PHP configuration files are created for both Apache and CLI environments to set memory limits, upload sizes, and execution timeouts.
-
Database Setup:
-
The MariaDB repository is added via a setup script.
-
MariaDB server and client packages are installed.
-
A dedicated database named
moodleis created withutf8mb4encoding. -
A specific user for Moodle is created and granted necessary privileges.
-
Moodle Application Installation:
-
The Moodle 5.1.1 archive is downloaded from the official source.
-
The archive is extracted to
/var/www. -
Permissions are configured so that the web server (
www-data) can access the required directories. -
A CLI installation script is executed to perform the initial database schema creation and admin user setup.
-
Web Server Configuration:
-
Apache is configured as a VirtualHost for port 80, pointing to
/var/www/moodle/public. -
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-datawith restricted read access (0640for files,0750for directories). -
Data Directory Protection: The
/var/moodledatadirectory is strictly restricted to the web server user with mode0770. -
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_setupis used to configure the official MariaDB repositories. -
Moodle Cron Job: A system cron job is created at
/etc/cron.d/moodleto run the Moodle CLI cron script every minute as thewww-datauser. This is essential for scheduled tasks within the application.
Application Update Instructions¶
To update the Moodle application, follow these steps:
-
Download and extract the new version of Moodle into
/var/www. -
Ensure the configuration files and directory permissions are maintained.
-
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 apache2orsystemctl status mariadb