Deployment Overview of Moodle on Server¶
Prerequisites and Basic Requirements¶
To ensure a successful deployment, the following requirements must be met:
-
Operating System: Debian-based distributions (e.g., Ubuntu or Debian).
-
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 download PHP repositories, MariaDB repositories, and the Moodle application archive.
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}.hostkey.in |
File and Directory Structure¶
The following directories are used for application files, data, and configurations:
-
/var/www/moodle: Main Moodle application directory. -
/var/moodledata: Moodle data directory (contains user files and cached content). -
/etc/php/{version}/apache2/conf.d/99-moodle.ini: PHP configuration for Apache. -
/etc/mysql/mariadb.conf.d/99-moodle.cnf: MariaDB server configuration. -
/etc/cron.d/moodle: System cron job for Moodle maintenance.
Application installation process¶
The application is installed using a combination of package management and manual configuration steps:
-
System Preparation: The system repositories are updated, and essential base packages (curl, gnupg, unzip, etc.) are installed.
-
PHP Installation: A dedicated PHP PPA is added to install PHP version
8.2along with necessary extensions includingmysql,xml,curl,zip,gd,intl,mbstring,soap, andbcmath. -
Database Setup:
-
The MariaDB repository is configured via a setup script.
-
MariaDB server and client are installed.
-
A database named
moodleis created withutf8mb4encoding. -
A dedicated database user
moodleis created and granted privileges. -
Moodle Installation:
-
The Moodle archive (version
5.1.1) is downloaded from the official Moodle website. -
The archive is extracted to
/var/www. -
Permissions are configured so that the web server (
www-data) can access necessary files while maintaining security for the core directory. -
The application is initialized via the Command Line Interface (CLI) using
php admin/cli/install.php, which generates theconfig.phpfile. -
Web Server Configuration:
-
Apache is configured as the web server with modules
rewrite,headers, andsslenabled. -
A VirtualHost is created to point to
/var/www/moodle/public.
Access Rights and Security¶
-
File Permissions: Moodle core files are owned by
root:www-datawith restricted permissions (0750for directories,0640for files) to prevent unauthorized access. -
Data Directory: The
/var/moodledatadirectory is strictly managed with0770permissions for thewww-datagroup. -
Firewall: Access is restricted via Apache configuration and SSL redirection.
Databases¶
The application utilizes MariaDB as its primary database engine.
| Parameter | Value |
|---|---|
| Database Name | moodle |
| Character Set | utf8mb4 |
| Collation | utf8mb4_unicode_ci |
| Connection Method | Localhost (Unix socket/TCP) |
Custom Scripts and Additional Setup¶
The following setup actions are performed to ensure the application functions correctly:
-
PHP Optimization: Custom
.inifiles are created in both Apache and CLI paths to increasememory_limit(256M),upload_max_filesize(100M), andmax_execution_time(300). -
Automated Maintenance: A cron job is established at
/etc/cron.d/moodlethat runs the Moodle CLI cron script every minute to handle background tasks.
Application Update Instructions¶
To update the main Moodle application:
-
Download the new version of the Moodle archive.
-
Extract the contents into the existing
/var/www/moodledirectory. -
Run the upgrade script via CLI:
Location of configuration files and data¶
-
Application Configuration:
/var/www/moodle/config.php -
User Data:
/var/moodledata -
Database Config:
/etc/mysql/mariadb.conf.d/99-moodle.cnf
Available ports for connection¶
-
80: HTTP (Redirected to HTTPS) -
443: HTTPS (Secure access)