Deploy Moodle 5.2 | Official Release, Postgres, Nightly Backups

Current Moodle LMS on Postgres, installed with no open setup page

Deploy Moodle 5.2 | Official Release, Postgres, Nightly Backups

Just deployed

/var/moodledata

/var/lib/postgresql/data

Backups

Bucket

Just deployed

Deploy and Host Moodle on Railway

Deploy on Railway

Moodle is the open-source learning platform used by schools, universities and companies worldwide: courses, assignments, quizzes, gradebook, forums, badges and certificates, with more than 2,000 plugins. This template runs the current official Moodle 5.2 release (5.2.3) on PostgreSQL.

About Hosting Moodle

Two services and a bucket:

  • Moodle runs PHP 8.4 and Apache with the official release package. The code is in the image; uploaded files, the site secret and caches live on the volume at /var/moodledata. Cron runs in the same service every minute, so scheduled tasks, emails and course backups work without extra setup.
  • Postgres 17, reachable only over Railway's private network.
  • Backups is a Railway bucket that gets a nightly copy of the database and the data directory.

Moodle is installed from the command line on first boot, with an admin password generated at deploy. The web installer is never reachable: until the install finishes, the site shows a "Moodle is starting" page.

Common Use Cases

  • An online school or course platform with enrolments, assignments, quizzes and grades
  • Staff training and onboarding with completion tracking and certificates
  • A course site for a single teacher, a tutoring business or a community

Dependencies for Moodle Hosting

  • A PostgreSQL database (included)
  • An SMTP server for email (optional; see below)

Deployment Dependencies

Implementation Details

After deploying: the first deploy takes about five minutes: about four to build the image and one to install Moodle. Then open the Moodle domain and log in as admin with MOODLE_ADMIN_PASSWORD from the Moodle service's Variables tab. Change the site name under Site administration → General → Site home settings, and the admin email in the admin's profile.

Email. Set up SMTP under Site administration → Server → Email → Outgoing mail configuration. Railway allows outbound SMTP only on the Pro plan and above; on Trial and Hobby, Moodle can't send email (Moodle has no HTTP-API mail option).

Custom domain. Add it in the service's Networking settings, then set MOODLE_URL to https://your.domain. Links already stored in course content still point to the old address; the "Search and replace" tool under Site administration → Development fixes those.

Plugins. The code is part of the image, so plugins are added there too and survive every redeploy. Fork the template repository, put each plugin under plugins/ at the path Moodle expects (for example plugins/mod/attendance), point the service at your fork and redeploy. The next start installs the plugin. Installing plugins from the admin page is turned off because the image is read-only.

Updates. Bump MOODLE_VERSION and its checksum in the Dockerfile and redeploy. The start script runs Moodle's command-line upgrade before serving the new release, and visitors see the "starting" page while it runs. Take a backup first (below).

Backups. Every night at 03:00 UTC the database dump and the data directory (without caches) go to the Backups bucket as moodle-.tar.gz, so the last seven days are kept. Run moodle-backup from railway ssh for an extra one before a risky change, and moodle-restore Mon to restore the backup of that day. Clear S3_BUCKET to turn nightly backups off.

Command line. `moodle


Template Content

More templates in this category

View Template
Libredesk - Complete Setup
Complete self-hosted omnichannel customer support desk.

codestorm
2
View Template
Paperless-ngx
Paperless-ngx — document management with OCR and full-text search

INAPP
1
View Template
Instatic CMS - Postgres
Design, build and manage powerful static sites from state-of-the-art CMS

Instatic
166