What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

You can run Moodle on Google Cloud Compute Engine by creating an Ubuntu 24.04 LTS virtual machine, installing one supported web server, PHP and its required extensions, a Moodle-compatible database, and then completing Moodle’s browser installer. The installation itself is straightforward; the production work is securing the VM, keeping moodledata outside the public web root, enabling HTTPS, scheduling cron, and testing backups.

This guide follows a practical path from an empty Google Cloud project to a maintainable Moodle site. It uses Apache as the example web server, but explains where Nginx differs. Substitute the PHP, database and extension requirements documented for your exact Moodle release before installing anything.

What do you need before installing Moodle on Google Cloud?

Prepare the cloud project, a domain name, an administrator account and a deployment plan before creating the VM. Moodle’s Ubuntu instructions require a supported Ubuntu 24 server with sudo or root access, a web server, a database and PHP.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Required decisions and resources

  • Google Cloud project: enable the Compute Engine API and ensure billing is enabled.
  • Operating system: Ubuntu 24.04 LTS. Google Cloud publishes this image in the ubuntu-os-cloud project for both x86 and Arm machine families. The current image lifecycle lists June 2029 as the end date and Extended Security Maintenance through April 2034.
  • Machine size: choose CPU, memory and disk for your expected concurrent users, file uploads, reporting jobs and database workload. Start with a modest general-purpose VM only when you have monitoring and a scale-up plan.
  • Storage: use a persistent disk with enough room for the operating system, Moodle code, uploaded files, database growth, logs and temporary upgrade space. Moodle’s moodledata can become much larger than the code directory.
  • DNS name: decide the final hostname before requesting a production TLS certificate. For example, use a dedicated name such as learn.example.org.
  • Administrative access: use SSH keys or the Google Cloud browser SSH facility, keep administrator access limited to trusted people, and avoid exposing database ports to the internet.

Which web server should you choose?

Apache and Nginx are alternatives, not components to install together. MoodleDocs states: “Apache or Nginx are given as options for a webserver. Install one or the other, not both.” Apache is often the easier choice for administrators who want broad Moodle community familiarity and straightforward PHP integration. Nginx can be a good fit when your team already operates Nginx and is comfortable configuring PHP-FPM, upload limits and rewrite rules explicitly.

How do you create the Ubuntu VM in Google Cloud?

Create the VM from Compute Engine, select Ubuntu 24.04 LTS, and allow HTTP traffic temporarily so you can verify the first web response. Add HTTPS and tighten access before calling the site production-ready.

  1. In the Google Cloud console, select the intended project and open Compute Engine.
  2. Open VM instances, choose Create instance, and give the VM a descriptive name and region. Pick a zone near your users and any other services the site will call.
  3. Under the boot disk, select the Ubuntu 24.04 LTS image. Confirm that the image family is from the ubuntu-os-cloud project rather than an unrelated custom image.
  4. Choose a machine type appropriate to your expected Moodle load. Leave room to resize the VM if memory pressure, PHP worker exhaustion or database latency appears in monitoring.
  5. Configure a persistent boot disk and decide whether Moodle files should use an additional persistent disk. A separate disk can simplify capacity expansion and recovery, but it does not replace off-VM backups.
  6. In the firewall section, allow HTTP traffic for the initial setup. You will add HTTPS and redirect HTTP later; do not leave a broad temporary rule as your final security posture.
  7. Create the instance and wait until its status is running. Record its external IP address.
  8. Create a DNS A record for the final hostname pointing to that address. If the address must remain stable, reserve and attach a static external IP before production DNS changes.

The Google Cloud creation workflow documents the initial HTTP firewall choice. A public Moodle deployment should ultimately serve HTTPS, restrict administrative access and remove any firewall rule that is no longer necessary.

How do you connect to the VM and prepare Ubuntu?

Connect over SSH, patch the operating system, and use a least-privilege administrator account. Do not perform routine work as the root user.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. From the VM details page, select SSH, or connect with your approved local SSH key. Confirm that the host fingerprint is expected.
  2. Update package metadata and installed packages:
sudo apt update
sudo apt full-upgrade -y
  1. Confirm the account you will use has sudo access. If you create an additional administrator, test a second SSH session before closing the original one.
  2. Set the correct time zone and verify time synchronization. Accurate time matters for logs, scheduled tasks, certificate checks and troubleshooting.
  3. Review the VM’s network rules. Allow SSH only from trusted administrator networks where practical. Do not create public ingress rules for MySQL, MariaDB or PostgreSQL ports.
  4. Install basic operational tools such as a text editor, an archive utility and a process monitor according to your team’s standard. Keep the base system minimal.

How do you install Apache, PHP and Moodle’s required extensions?

Install one web server and the PHP version and extensions required by the exact Moodle release. Requirements change between Moodle releases, so check that release’s Ubuntu documentation immediately before installation instead of assuming that a package set for an older version remains valid.

Apache example

The following is a typical starting point for an Apache-based deployment on Ubuntu. Treat the extension list as a checklist to reconcile with your chosen Moodle release, not as a substitute for its requirements page.

sudo apt install -y apache2 libapache2-mod-php php php-cli php-common 
  php-curl php-gd php-intl php-mbstring php-mysql php-soap php-xml 
  php-zip unzip

Enable the Apache modules your configuration needs, then restart Apache after changing PHP or virtual-host settings:

sudo a2enmod rewrite
sudo systemctl enable --now apache2
sudo systemctl restart apache2

Check the installed PHP version and loaded modules with php -v and php -m. Adjust PHP limits for the largest course backups and uploads your users will handle. Common settings include memory_limit, upload_max_filesize, post_max_size and the maximum execution time. Set values based on your Moodle workload, then restart Apache and verify that the effective values changed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Nginx alternative

With Nginx, install Nginx and PHP-FPM instead of Apache and libapache2-mod-php. Configure a server block whose document root is the Moodle code directory, pass PHP requests to the matching PHP-FPM socket, and implement the rewrite and security rules required by your Moodle release. Nginx does not read Apache .htaccess files, so copying an Apache configuration without translating its rules can produce broken URLs or expose files.

Whichever server you choose, check that the web process can execute PHP, that static files are served, and that a temporary test file is removed immediately after testing. Never leave a diagnostic page such as phpinfo() accessible on a public hostname.

How do you install and secure the Moodle database?

Use a Moodle-supported database engine and version, create a dedicated database and user, select a UTF-8-capable character set and collation, and keep the service on the VM’s private interface unless you have deliberately chosen a managed database design.

MariaDB or MySQL approach

  1. Install the database server and client packages from Ubuntu’s repositories, or use another supported source approved by your organization.
  2. Run the database hardening utility, remove anonymous accounts and test databases, and disable remote administrative login.
  3. Create a database dedicated to Moodle and a user dedicated to that database. Generate a long random password and store it in your password manager; do not put it in a public script or commit it to source control.
  4. Set the database’s default character set and collation to the UTF-8 variant required by your Moodle release. Confirm the actual defaults after creation.
  5. Grant only the privileges Moodle needs on its own database. Do not reuse an operating-system account or a shared application credential.
  6. Verify the database version against the release-specific Moodle requirements before importing any production data.
sudo apt update
sudo apt install -y mariadb-server mariadb-client
sudo mariadb-secure-installation
sudo mariadb

Inside the database client, use your own database name and a newly generated secret:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
CREATE DATABASE moodle CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'moodleapp'@'localhost' IDENTIFIED BY 'Use-a-long-random-secret-here';
GRANT ALL PRIVILEGES ON moodle.* TO 'moodleapp'@'localhost';
FLUSH PRIVILEGES;
EXIT;

The exact collation and privilege syntax must match the database engine and Moodle release you selected. If you use PostgreSQL instead, follow Moodle’s PostgreSQL-specific requirements rather than applying MySQL or MariaDB commands.

Network and database protections

  • Bind the database to localhost or the VM’s private address when no remote client is required.
  • Use Google Cloud firewall rules to deny public database ingress even if a package changes its listener configuration.
  • Encrypt and restrict access to database backups. A database dump contains account data, course content and potentially private submissions.
  • Monitor disk space: a full database volume can stop logins, submissions and scheduled tasks.

How do you download Moodle and keep moodledata safe?

Download the intended Moodle release from Moodle’s official distribution channel, verify the archive where possible, place the application code in the web root, and create moodledata outside that root. The separation is a critical security boundary: uploaded files and generated content must not be directly executable or browsable by URL.

  1. Change to a staging directory and obtain the Moodle archive for the release you selected.
  2. Verify its checksum or signature against the value published with the release when available.
  3. Extract the code into a dedicated directory such as /var/www/moodle, preserving the release’s file structure.
  4. Create a data directory outside the document root, for example /var/moodledata. Do not create it inside /var/www/moodle.
  5. Assign ownership so the web-server account can read the application and write only to the locations Moodle requires. Keep configuration files and system directories owned by root where possible.
  6. Apply restrictive permissions. Avoid making either the code or data directory world-writable.
sudo mkdir -p /var/www/moodle /var/moodledata
sudo chown -R www-data:www-data /var/www/moodle /var/moodledata
sudo chmod 750 /var/moodledata

The ownership command is a starting point for Apache’s common www-data account. Confirm the actual account used by Nginx/PHP-FPM or your distribution before applying it. If your deployment process owns the code, give the web process write access only to required writable paths rather than recursively granting write access to every file.

How do you configure the web server and run Moodle’s installer?

Point the virtual host at the Moodle code directory, enable the rewrite behavior required by your server, and open the site over its DNS name. Moodle’s browser installer then asks for the site URL, data directory, database credentials and the first administrator account.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Apache virtual host

Create a dedicated Apache site configuration with the final hostname and Moodle document root. Enable the site, disable the default site if it conflicts, and reload Apache. Set directory permissions and rewrite rules according to the Moodle release documentation. Do not expose /var/moodledata through an Alias or a second public virtual host.

sudo a2ensite moodle.conf
sudo a2dissite 000-default.conf
sudo apache2ctl configtest
sudo systemctl reload apache2

If configtest reports an error, fix it before reloading. Check Apache’s error log and the system journal when the browser shows a 500 response.

Complete the browser installation

  1. Visit the temporary HTTP address or, preferably, the DNS hostname once it resolves.
  2. Choose the language and confirm the detected server paths. Set the data directory to the external moodledata path.
  3. Enter the database type, host, database name, user and password created for Moodle. Use a local database host when the database runs on the same VM.
  4. Review the environment checks. Stop and fix missing PHP extensions, insufficient limits, unsupported versions or unwritable directories rather than bypassing warnings.
  5. Create the first administrator account with a unique, long password and a recovery email address controlled by your organization.
  6. Set the site name, short name and final URL. The configured URL must match the HTTPS hostname users will actually visit; changing it later requires careful configuration and cache clearing.

After installation, remove any downloaded archive and temporary test files. Keep the Moodle code at a known release and record the version, PHP version, database version and VM image for future maintenance.

How do you enable HTTPS and lock down the public site?

Obtain a trusted TLS certificate after DNS points to the VM, configure the web server for HTTPS, redirect HTTP to HTTPS, and then narrow firewall access. Do not treat the initial “allow HTTP” checkbox in the VM wizard as a complete production configuration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Confirm the DNS A record resolves to the VM’s current static external IP.
  2. Issue a certificate through your organization’s approved certificate authority and configure the certificate chain and private key with restrictive permissions.
  3. Add an HTTPS virtual host/server block for the Moodle hostname.
  4. Redirect all HTTP requests to the equivalent HTTPS URL, excluding only the validation path required by your certificate process.
  5. Set Moodle’s configured URL to the final https:// address and confirm that login, file downloads and redirects remain on HTTPS.
  6. Allow TCP 443 in the Google Cloud firewall and remove broad temporary rules that are no longer needed. Keep SSH restricted to administrators.
  7. Renew certificates before expiry and test renewal without interrupting scheduled Moodle jobs.

Review cookies, reverse-proxy headers and trusted hosts if you place a load balancer or proxy in front of the VM. A mismatch between proxy headers and Moodle’s HTTPS setting can cause redirect loops or insecure links.

How do you schedule Moodle cron and verify the installation?

Moodle cron processes scheduled tasks such as forum notifications, backups, enrolment updates and cleanup. Configure it at the interval recommended for your exact Moodle release, run it as the web-server account, and monitor failures instead of assuming a successful web login means cron works.

Example cron entry

After confirming the correct PHP binary and Moodle path, add a system cron entry similar to the following. Use the interval specified by your release documentation and workload; the one-minute example is common for sites that need prompt task processing.

* * * * * www-data /usr/bin/php /var/www/moodle/admin/cli/cron.php >/dev/null 2>&1

On systems that use a different cron format, place the command in the appropriate file. Run the command manually once as the same account and inspect its output. Moodle’s scheduled-task administration page should show recent successful runs and identify tasks that are failing repeatedly.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Functional verification checklist

  • Open the site over HTTPS from an external network.
  • Log in as the administrator and confirm the site URL and environment checks.
  • Create a test course, enrol a test account and upload a file larger than a few megabytes.
  • Send a test message or notification and verify outgoing mail through your approved mail service.
  • Run cron manually, then confirm scheduled-task timestamps advance.
  • Review Apache or Nginx, PHP and database logs for warnings and authentication failures.
  • Check CPU, memory, disk, inode usage and persistent-disk growth in Google Cloud monitoring.
  • Test a backup and restoration procedure before inviting real learners.

How should you back up and maintain Moodle on Google Cloud?

Back up the database and moodledata separately, retain copies outside the VM, and perform restoration tests. A disk snapshot alone is not a complete Moodle backup because it may capture an inconsistent database and does not prove that individual courses can be restored.

Backup plan

  • Database: schedule consistent dumps or use a supported managed-database backup method. Encrypt the output and restrict access.
  • Files: back up moodledata, including uploaded course files, generated content and caches that your recovery plan requires. Back up Moodle configuration and custom themes separately.
  • Off-VM copies: keep at least one copy outside the Compute Engine VM and protect it from the same administrator credentials and failure domain.
  • Retention: define daily, weekly and monthly retention based on your recovery-point objectives and data-retention obligations.
  • Testing: restore to an isolated environment, verify logins and course files, and document the time required.

Patch and upgrade routine

  1. Read the target Moodle release requirements before changing PHP, the database engine or the operating system.
  2. Take verified database and file backups.
  3. Test the upgrade on a clone or staging VM, including plugins, themes, cron and mail.
  4. Schedule a maintenance window, enable Moodle maintenance mode and apply updates in the supported order.
  5. Run upgrade tasks, clear caches as directed, disable maintenance mode and execute cron.
  6. Monitor error logs and user-facing workflows after release.

Apply Ubuntu, PHP, web-server, database and Moodle security updates on a planned schedule. Keep a written inventory of versions and changes so a failed upgrade can be reversed or diagnosed quickly.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What commonly breaks during a Moodle installation?

The installer reports missing extensions

Compare the exact Moodle release requirements with php -m, install the missing package for the active PHP version, restart the web server or PHP-FPM, and reload the environment-check page. Multiple PHP versions on one VM can leave the command-line PHP and web PHP using different extension sets.

Uploads fail or large backups time out

Raise PHP’s upload, POST and execution limits consistently, then adjust the web server’s request-body limit and timeout. Confirm that the VM has sufficient memory and disk space. Test with a representative course backup rather than relying on a tiny file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Moodle cannot write to moodledata

Check the effective web-process account, directory ownership, parent-directory traversal permissions and available disk space. Keep the directory outside the public root and avoid solving the error with world-writable permissions.

Users see redirect loops after HTTPS is enabled

Check Moodle’s configured HTTPS URL, the virtual host redirect, reverse-proxy headers and any trusted-proxy setting. Ensure the proxy communicates the original scheme correctly and that only one layer performs the canonical redirect.

Cron shows overdue tasks

Run the CLI cron command manually as the configured service account. Inspect PHP and web-server logs, verify the PHP binary path, confirm file and database connectivity, and check whether the VM is starved for CPU, memory or disk. Correct the underlying task failure before shortening the interval.

The site is slow or runs out of memory

Inspect database queries, PHP worker limits, cron concurrency, disk latency and available RAM. Resize the Compute Engine VM or add a separate database service only after identifying the bottleneck. Keep monitoring enabled so a capacity change can be evaluated rather than guessed.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Should you self-host Moodle on Compute Engine or use managed hosting?

Self-hosting is appropriate when your team needs direct control of the VM, networking, plugins, data location and maintenance schedule and can operate the full application stack. Managed Moodle hosting is a legitimate alternative when the team does not want to maintain Linux, PHP, the database, certificates, backups and monitoring itself.

Decision area Compute Engine self-hosting Managed Moodle hosting
Control and customization Direct control of the VM, web server, database, plugins and network rules. Some infrastructure and platform choices are controlled by the provider; confirm plugin and configuration limits.
Operational workload Your team patches Ubuntu, PHP, the web server and Moodle, and responds to incidents. The provider handles an agreed portion of infrastructure and application operations.
Backup and recovery You design retention, off-VM storage and restoration tests. Review exactly what is backed up, how long it is retained and whether restores are included.
Scaling You resize the VM, redesign storage or add services as demand changes. Scaling may be simpler, but capacity, architecture and limits depend on the service plan.
Support Google Cloud support and your own administrators handle the stack boundaries. One provider may offer application-focused support; verify response times and escalation scope.
Data location You select the Google Cloud region and control storage placement. Confirm the provider’s regions, subprocessors and data-residency terms.
Total cost Includes VM, persistent disks, network traffic, backups, monitoring and staff time. Includes the hosting fee and any limits or add-ons; compare it with the internal labor you would otherwise supply.

Choose Compute Engine when control and customization justify operating the stack. Choose managed hosting when predictable administration and support are more valuable than direct infrastructure control. In either case, require a documented backup and exit plan.

What is the safest production checklist for a new Moodle VM?

  • Ubuntu 24.04 LTS is patched and the Moodle release supports the installed PHP and database versions.
  • Only one web server is installed and configured correctly.
  • The database has a dedicated least-privilege user, UTF-8 settings and no public ingress.
  • moodledata is outside the public web root and writable only by the required service account.
  • The final HTTPS hostname resolves to a stable VM address and HTTP redirects to HTTPS.
  • SSH is restricted to trusted administrators; unused firewall rules are removed.
  • Cron runs successfully at the release-recommended interval.
  • Database and file backups are encrypted, stored outside the VM and restored successfully in a test.
  • Monitoring and alerts cover disk, memory, CPU, certificate expiry, cron failures and web/database errors.
  • A documented upgrade and rollback procedure exists before learners are onboarded.

Frequently Asked Questions

Can Moodle run on an Arm Google Cloud VM?

Google Cloud publishes Ubuntu 24.04 LTS image families for both x86 and Arm. Confirm that your selected Moodle release, PHP extensions, database packages and any proprietary plugins support the architecture before choosing Arm for production.

Do I need a static external IP for Moodle?

A stable address is strongly preferable for DNS and certificate management. Reserve a static external IP or use an equivalent stable front end so a VM stop, restart or replacement does not unexpectedly change the hostname’s destination.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can I move an existing Moodle site to Google Cloud later?

Yes, migration normally involves restoring the database, copying the required Moodle files and moodledata, matching supported PHP and database versions, and updating the configured site URL. Plan a maintenance window and test the restore on a separate VM before switching DNS.

How do I estimate the VM size Moodle needs?

There is no single safe size because concurrency, plugins, reporting, file processing and cron workload differ widely. Start with a monitored machine, load-test representative activities, and scale after observing memory, CPU, database latency and PHP worker saturation rather than relying on enrollment counts alone.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.