Skip to content

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:

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

  2. PHP Installation: A dedicated PHP PPA is added to install PHP version 8.2 along with necessary extensions including mysql, xml, curl, zip, gd, intl, mbstring, soap, and bcmath.

  3. Database Setup:

  4. The MariaDB repository is configured via a setup script.

  5. MariaDB server and client are installed.

  6. A database named moodle is created with utf8mb4 encoding.

  7. A dedicated database user moodle is created and granted privileges.

  8. Moodle Installation:

  9. The Moodle archive (version 5.1.1) is downloaded from the official Moodle website.

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

  11. Permissions are configured so that the web server (www-data) can access necessary files while maintaining security for the core directory.

  12. The application is initialized via the Command Line Interface (CLI) using php admin/cli/install.php, which generates the config.php file.

  13. Web Server Configuration:

  14. Apache is configured as the web server with modules rewrite, headers, and ssl enabled.

  15. 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-data with restricted permissions (0750 for directories, 0640 for files) to prevent unauthorized access.

  • Data Directory: The /var/moodledata directory is strictly managed with 0770 permissions for the www-data group.

  • 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 .ini files are created in both Apache and CLI paths to increase memory_limit (256M), upload_max_filesize (100M), and max_execution_time (300).

  • Automated Maintenance: A cron job is established at /etc/cron.d/moodle that runs the Moodle CLI cron script every minute to handle background tasks.

Application Update Instructions

To update the main Moodle application:

  1. Download the new version of the Moodle archive.

  2. Extract the contents into the existing /var/www/moodle directory.

  3. Run the upgrade script via CLI:

    php /var/www/moodle/admin/cli/upgrade.php
    

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)

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