This guide covers the layout and day-two configuration of the CloudSOE Moodle image on both AWS and Azure. It assumes you’ve finished one of the getting-started guides (AWS, Azure).

File locations

PathPurpose
/var/www/moodleMoodle code root (Apache serves the public/ subdirectory)
/var/www/moodle/config.phpSite configuration, including wwwroot (generated at first boot)
/var/moodledataMoodle data directory — course files, uploads, caches
/opt/moodle/default-moodle-credentials.txtGenerated credentials (mode 600)
/etc/apache2/sites-enabled/moodle.confApache virtual host (HTTP redirect + HTTPS)
/etc/ssl/certs/moodle-selfsigned.crtPer-instance TLS certificate
/etc/ssl/private/moodle-selfsigned.keyPer-instance TLS private key

Moodle 5.x serves only public/ under the code root — config.php, lib/ and the CLI tools are deliberately not web-accessible.

Services and cron

Apache and MariaDB are managed by systemd and enabled at boot:

sudo systemctl status apache2 mariadb
sudo systemctl restart apache2      # after config changes

The one-time setup service moodle-firstboot only runs until it succeeds once; after that it exits immediately thanks to its marker file (/var/lib/moodle-firstboot.done).

Moodle’s background task runner is already installed as a system cron job that runs admin/cli/cron.php every minute as www-data — no action needed on your part.

Database access

The site uses a local MariaDB database:

  • Database: moodle
  • User: moodle
  • Password: in the credentials file

Connect from the shell with sudo mysql moodle, or use phpMyAdmin at https://<your-ip>/phpmyadmin with the moodle database user. If you don’t need phpMyAdmin, remove it:

sudo apt remove --purge phpmyadmin

Replacing the self-signed certificate

The image generates a self-signed certificate at first boot so HTTPS works immediately, but browsers won’t trust it. Once your domain points at the instance, switch to Let’s Encrypt:

sudo apt install certbot python3-certbot-apache
sudo certbot --apache -d moodle.example.com

Alternatively, install a purchased certificate and key at the paths in the table above, then sudo systemctl reload apache2 — always replace both files together.

Pointing a domain at your site

  1. Create an A record for your domain pointing at the instance’s public IP (on AWS, allocate an Elastic IP first so the address survives stop/start; on Azure, set the public IP to Static).
  2. Moodle pins its own URL in config.php, so update wwwroot there:
sudo nano /var/www/moodle/config.php
# change:  $CFG->wwwroot = 'https://<old-ip>';
# to:      $CFG->wwwroot = 'https://moodle.example.com';

Uploading files over SFTP

The admin user (debian on AWS, your chosen username on Azure) is added to the www-data group at first boot with write access to /var/moodledata. The Moodle code itself stays read-only. Any SFTP client works with your SSH key:

sftp debian@<public-ip>
sftp> cd /var/moodledata

PHP settings

PHP 8.4 runs through libapache2-mod-php8.4 (Moodle 5.2 requires PHP 8.3–8.4, so the version is pinned). Moodle-recommended settings already ship in a drop-in — raise them there if needed:

sudo nano /etc/php/8.4/apache2/conf.d/99-moodle.ini
# max_input_vars = 5000, upload_max_filesize = 256M,
# post_max_size = 256M, memory_limit = 512M
sudo systemctl restart apache2

Next steps

  • Tips & tricks — backups, updates, performance and troubleshooting