Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →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
To run Moodle reliably on Ubuntu, install it on a supported Ubuntu 24 server with Apache, PHP-FPM and a supported database, keep moodledata outside the web root, and publish the site through HTTPS. Obtain and test a valid certificate on the Apache origin first; then proxy the hostname through Cloudflare and select Full (strict). This sequence prevents the common Flexible-mode redirect loop and preserves a trustworthy client IP for logs and rate limits. The guide below follows the Apache path only: Apache and Nginx are alternatives, not components to install together.
What architecture should you build?
A sound deployment has four layers: Ubuntu 24 as the host, Apache as the web server, PHP 8.3-FPM as the PHP execution service, and a supported database for Moodle. Cloudflare sits in front of the public hostname as DNS and an optional reverse proxy. The browser connects to Cloudflare over HTTPS, Cloudflare connects to Apache over HTTPS, and Apache passes PHP requests to the FPM socket.
- Public code directory: the Moodle application directory, used as Apache’s
DocumentRoot. - Private data directory:
moodledata, outside the document root so uploaded files and cache data cannot be requested directly. - Origin TLS: a certificate installed on Apache before Cloudflare is switched to strict validation.
- Application URL: Moodle’s
wwwrootmust exactly match the public HTTPS hostname.
Use one web server. The Ubuntu Moodle guide treats Apache and Nginx as alternatives; installing both adds competing listeners and makes troubleshooting needlessly difficult.
Free tools Windows power users keep installed
One-click scans. No signup required.
What do I need before installing Moodle?
You need a sudo-capable Ubuntu 24 server, a DNS name you control, and a Moodle release whose PHP and database requirements you have checked. Requirements change between Moodle releases, so select the Moodle version first and then install the PHP extensions and database engine that its release documentation lists.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Prerequisites checklist
- Ubuntu 24 server with a stable hostname and sufficient disk space for the code, database, backups and course files.
- Root or sudo access.
- A DNS A or CNAME record for the final Moodle hostname.
- A database server and a dedicated database account for Moodle.
- TCP ports 80 and 443 allowed through the host firewall and any cloud security group.
- A plan for scheduled Moodle cron execution and backups.
Use a hostname such as moodle.example.net in the examples below. Replace it with your real name; it is not a value to leave in production.
How do I prepare Ubuntu and the Moodle directories?
Update the operating system, create a code directory and create moodledata somewhere Apache can write but the web server cannot serve as public files.
sudo apt update
sudo apt full-upgrade -y
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 can be refined after the Moodle code is unpacked. Keep the data path outside /var/www/moodle; moving it into the document root defeats an important security boundary.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Which Apache and PHP packages should I install?
Install Apache, the FastCGI connector, PHP 8.3-FPM and CLI, plus the extensions required by your selected Moodle release. The following command is a practical Ubuntu 24 starting point; verify the exact extension list against that release before running it.
sudo apt install -y apache2 libapache2-mod-fcgid
php8.3-fpm php8.3-cli php8.3-common php8.3-curl php8.3-gd
php8.3-intl php8.3-mbstring php8.3-mysql php8.3-soap
php8.3-xml php8.3-zip php8.3-bcmath
If your Moodle release requires PostgreSQL rather than MySQL-compatible software, install the corresponding PHP database extension and server instead. Do not assume that a package name or PHP version valid for one Moodle release is valid for every release.
Enable the Apache modules needed for PHP-FPM and Moodle’s rewrite behavior, then enable the FPM service:
sudo a2enmod proxy_fcgi setenvif rewrite
sudo systemctl enable --now apache2 php8.3-fpm
How do I configure Apache for Moodle clean URLs?
Create a dedicated virtual host. Set the Moodle public directory as DocumentRoot, grant Apache access to it, provide normal index files, and send requests that are not real files to Moodle’s /r.php front controller.
sudo nano /etc/apache2/sites-available/moodle.conf
<VirtualHost *:80>
ServerName moodle.example.net
DocumentRoot /var/www/moodle
<Directory /var/www/moodle>
Options FollowSymLinks
AllowOverride All
Require all granted
DirectoryIndex index.php index.html
FallbackResource /r.php
</Directory>
<FilesMatch ".php$">
SetHandler "proxy:unix:/run/php/php8.3-fpm.sock|fcgi://localhost/"
</FilesMatch>
ErrorLog ${APACHE_LOG_DIR}/moodle-error.log
CustomLog ${APACHE_LOG_DIR}/moodle-access.log combined
</VirtualHost>
FallbackResource /r.php is what routes a clean Moodle URL that is not an actual file to Moodle’s router. The FilesMatch handler sends PHP files to the PHP-FPM socket rather than using an embedded PHP module.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Enable the site, disable the default site if it is not needed, check syntax and reload:
sudo a2ensite moodle.conf
sudo a2dissite 000-default.conf
sudo apachectl configtest
sudo systemctl reload apache2
Apache should report Syntax OK. If it cannot find the socket, confirm that php8.3-fpm is running and inspect /run/php/ for the actual socket name.
Which PHP limits should I set for Moodle?
The Ubuntu Moodle guide specifies these defaults in both the FPM and CLI configurations: max_input_vars = 5000, post_max_size = 256M, and upload_max_filesize = 256M. They are guide defaults, not a promise that every course upload or server workload will fit within them.
sudo nano /etc/php/8.3/fpm/php.ini
sudo nano /etc/php/8.3/cli/php.ini
Set or update:
max_input_vars = 5000
post_max_size = 256M
upload_max_filesize = 256M
post_max_size should be at least as large as upload_max_filesize. Save both files and reload FPM:
sudo systemctl reload php8.3-fpm
After installation, use Moodle’s environment checks to identify any additional PHP setting required by the selected release. Do not increase limits simply to hide a failing check; larger request bodies also increase resource consumption.
How do I download Moodle and set its permissions?
Obtain the exact Moodle release from its official distribution channel, unpack it into /var/www/moodle, and make the web-server account the owner. Keep the release version recorded so you can reproduce upgrades and rollbacks.
cd /tmp
# Download the archive for the Moodle release you selected.
# Verify its checksum when one is published.
sudo tar -xzf moodle-<release>.tgz -C /var/www
sudo chown -R www-data:www-data /var/www/moodle
sudo find /var/www/moodle -type d -exec chmod 755 {} ;
sudo find /var/www/moodle -type f -exec chmod 644 {} ;
The archive name and extraction layout vary by release, so confirm that /var/www/moodle/index.php exists before proceeding. Do not make the entire tree world-writable.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
How do I create the Moodle database?
Create a dedicated database and user using the database engine supported by your Moodle release. The exact SQL differs between engines and releases; this MariaDB-style example illustrates the separation of privileges without claiming it is the only supported choice.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
sudo apt install -y mariadb-server
sudo systemctl enable --now mariadb
sudo mariadb
CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'moodleuser'@'localhost' IDENTIFIED BY 'use-a-long-random-password';
GRANT ALL PRIVILEGES ON moodle.* TO 'moodleuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Use a long unique password stored in a password manager. If you choose PostgreSQL or another supported engine, follow that engine’s Moodle-specific collation, extensions and privilege requirements instead of copying these statements.
How do I run the Moodle installer safely?
Set the data directory permissions, then open the HTTPS site once the origin certificate is ready, or use Moodle’s CLI installer if you prefer repeatable server setup. The web installer asks for the database host, database name, account, password and data path.
sudo chown -R www-data:www-data /var/moodledata
sudo chmod 770 /var/moodledata
During setup:
- Enter the final public URL, including
https://, when possible. - Set the data directory to
/var/moodledata, outside the document root. - Choose the database driver matching the server you installed.
- Run every environment check and correct warnings before creating the administrator account.
- After installation, review
config.phpownership and ensure it is not writable by untrusted users.
If you initially installed with HTTP, change Moodle’s wwwroot to the final HTTPS URL before opening the site to users. A mismatch between the configured URL and the browser URL causes redirects, broken links or blocked cookies.
How do I configure Moodle cron?
Moodle requires regular cron execution for queued tasks such as message delivery, scheduled backups and maintenance. Configure cron before inviting users; a site that works in the browser can still fail operationally when scheduled tasks never run.
Use the Moodle-documented CLI cron command and run it as the account that owns the Moodle files, normally www-data. A five-minute schedule is a common starting point, but use the cadence required by your release and workload.
sudo crontab -u www-data -e
*/5 * * * * /usr/bin/php /var/www/moodle/admin/cli/cron.php >/dev/null 2>&1
After adding it, check Moodle’s scheduled-task status and system logs. Keep cron output available during initial testing rather than discarding it immediately if you need to diagnose permissions or PHP errors.
How do I put HTTPS on the Apache origin?
Cloudflare’s strict mode only works when Apache accepts HTTPS on port 443 and presents an unexpired certificate whose name matches the Moodle hostname. Obtain that certificate and verify the origin directly before enabling the proxy.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problems- Allow TCP 80 and 443 in the host firewall and any upstream firewall.
- Install Certbot and its Apache integration:
sudo apt install -y certbot python3-certbot-apache. - Request a certificate for the real hostname:
sudo certbot --apache -d moodle.example.net. - Choose HTTP-to-HTTPS redirection when prompted, or configure an equivalent port-80 redirect in Apache.
- Run
sudo apachectl configtestand reload Apache. - Test
https://moodle.example.netwhile the DNS record points directly to the server, or test the origin by another controlled method.
You may use a publicly trusted certificate such as one issued by Let’s Encrypt, or a Cloudflare Origin CA certificate when the connection is intended to pass through Cloudflare. An Origin CA certificate is not a general public-browser certificate, so direct browser testing must follow the certificate’s trust model.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
How do I connect the hostname to Cloudflare?
Create an A record pointing to the server address, or a CNAME to the hostname that resolves to it. Once the origin works over HTTPS, switch the web record to Proxied in Cloudflare.
- Add the Moodle hostname to the Cloudflare zone.
- Create the A or CNAME record with the correct target.
- Leave proxying disabled while validating the origin certificate and Apache virtual host.
- Enable the orange-cloud proxy after direct HTTPS succeeds.
- In Cloudflare SSL/TLS settings, select Full (strict).
Full (strict) encrypts both browser-to-Cloudflare and Cloudflare-to-origin traffic and validates the origin certificate. Cloudflare’s guidance recommends Full (strict) whenever possible. The origin certificate must be unexpired and have a matching common name or SAN.
Why does Cloudflare Flexible mode create a redirect loop?
Flexible mode leaves the Cloudflare-to-origin connection on HTTP. If Apache redirects every HTTP request to HTTPS, Cloudflare requests HTTP at the origin, receives a redirect, and sends the browser back through the same cycle.
Recommended Free Tools
Use Full or, preferably, Full (strict) when Apache redirects HTTP to HTTPS. If a loop remains after changing the mode, check for a second redirect rule in Apache, a Moodle wwwroot still set to HTTP, or an origin that is not actually listening on 443.
Redirect-loop recovery checklist
- Confirm the Cloudflare mode is not Flexible.
- Open the origin directly and verify its certificate and hostname.
- Check Apache’s port-80 and port-443 virtual hosts for conflicting redirects.
- Set Moodle’s
wwwrootto the single canonical HTTPS URL. - Clear browser and Cloudflare cached redirects only after the origin configuration is correct.
How do I preserve the real client IP behind Cloudflare?
With a proxied record, Apache sees a Cloudflare address as the network peer. Cloudflare carries the visitor’s original address in CF-Connecting-IP and X-Forwarded-For. If you do nothing, access logs, fail2ban-style tools and rate limits can treat all visitors as the same Cloudflare source.
Configure your logging or reverse-proxy handling to use the Cloudflare header only when the request arrived from a Cloudflare network. Trusting that header from every Internet address allows clients to forge their apparent IP.
Safe header-handling pattern
- Obtain Cloudflare’s current published IPv4 and IPv6 ranges and keep them updated.
- Configure Apache’s real-IP handling, or the component that consumes logs, to trust
CF-Connecting-IPonly from those ranges. - Use the resulting client address for access logs, auditing and rate limits.
- Keep the original proxy address available for troubleshooting.
- Recheck the configuration whenever Cloudflare publishes a range change.
The exact Apache directive layout depends on the modules and logging stack you use. Do not paste an old, incomplete IP-range list into production; an outdated trust list either loses real addresses or trusts a network that should no longer be trusted.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Should I use Apache, Nginx, direct DNS or Cloudflare proxying?
There is no universal winner; choose according to operational familiarity, certificate ownership and whether you need Cloudflare’s edge controls.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
| Decision | Option | Advantages | Trade-offs |
|---|---|---|---|
| Web server | Apache | Matches this procedure, supports the shown FPM handler and familiar per-directory controls. | Requires careful module and virtual-host configuration. |
| Web server | Nginx | Valid alternative in Moodle’s Ubuntu guidance and common for high-throughput deployments. | Uses different PHP-FPM and routing configuration; do not install it alongside Apache for this site. |
| DNS path | Direct origin | Simpler request path and straightforward source-IP logging. | Exposes the origin address and provides no Cloudflare proxy layer. |
| DNS path | Cloudflare proxied | Hides the origin address and supplies edge TLS, DNS and traffic controls. | Apache must correctly trust forwarded headers and maintain an origin certificate. |
| Origin certificate | Let’s Encrypt | Publicly trusted and suitable for direct browser access. | Requires automated renewal and renewal testing. |
| Origin certificate | Cloudflare Origin CA | Designed for encrypted Cloudflare-to-origin traffic. | Not intended for general direct access when Cloudflare is bypassed. |
| Cloudflare TLS | Full | Encrypts the origin leg without strict certificate validation. | Does not verify that the origin certificate is trusted and correctly named. |
| Cloudflare TLS | Full (strict) | Encrypts and validates the origin certificate. | Fails if the certificate is expired, mismatched or absent. |
| Operations | Self-managed Ubuntu | Full control over Apache, PHP-FPM, database, cron and upgrades. | You own patching, backups, monitoring, certificates and recovery. |
| Operations | Managed Moodle hosting | Reduces routine server administration. | Less infrastructure control and provider-specific limits; evaluate support and Moodle-version policy carefully. |
What should I check before opening Moodle to users?
Run this final acceptance checklist after Cloudflare proxying is enabled:
https://loads the expected Moodle hostname without a redirect loop.- The certificate presented at the origin matches the hostname and has a renewal plan.
- Cloudflare SSL/TLS mode is Full (strict).
- Moodle’s
wwwrootuses the same HTTPS URL users enter. moodledatais outside the document root and writable only by the intended service account.- PHP-FPM is enabled, running and connected through the socket named in Apache’s
FilesMatchblock. - The Moodle environment check is clean for the selected release.
- Uploads larger than ordinary form submissions are tested within the configured 256 MB limits.
- Cron runs repeatedly and scheduled-task failures are visible to administrators.
- Logs show the real client address only after trusted Cloudflare header handling is configured.
- Database backups, Moodle file backups and a restore procedure have been tested.
How do I troubleshoot common installation failures?
Apache returns 503 or downloads PHP files
Check that php8.3-fpm is running, that the socket in moodle.conf exists, and that proxy_fcgi is enabled. Review the Moodle virtual-host error log and run apachectl configtest after every configuration change.
Moodle reports that the data directory is unsafe
Move moodledata outside the document root, correct its ownership and ensure Apache can write to it. Do not solve the warning by granting broad write permissions to the entire server filesystem.
Large uploads fail despite the Moodle setting
Confirm both FPM and CLI configuration files contain the documented values, reload FPM, and check whether Apache, Cloudflare or another upstream component imposes a smaller request limit. The effective value is the smallest limit in the request path.
Cloudflare reports an origin certificate error
Verify that Apache listens on 443, the certificate is unexpired, and its common name or SAN matches the Moodle hostname. Full (strict) deliberately refuses an origin that cannot satisfy those checks.
All users appear to come from one IP
That is expected at the network layer when proxying is enabled. Configure trusted handling for CF-Connecting-IP or X-Forwarded-For using current Cloudflare ranges; never trust those headers from arbitrary Internet clients.
Clean URLs return 404 errors
Confirm the virtual host’s DocumentRoot is the Moodle code directory, FallbackResource /r.php is inside the matching Directory block, and Apache has been reloaded after enabling the site. Check that r.php exists in the installed Moodle release.
Frequently Asked Questions
How often should Moodle cron run on a small site?
Run it at least as frequently as the release documentation and your scheduled tasks require; a five-minute schedule is a practical starting point. Watch the scheduled-task administration page after deployment because a successful cron process can still contain individual task failures.
Can I expose the Moodle origin directly for administration?
You can, but bypassing the proxy changes certificate trust, source-IP behavior and access controls. If direct access is necessary, restrict it with firewall rules or a private administration path and ensure the certificate and Moodle hostname remain consistent.
What should be backed up besides the Moodle database?
Back up the Moodle code version, the complete moodledata directory and the configuration containing database credentials. A database-only backup cannot restore uploaded course files, and a file-only backup cannot restore enrolled users or grades.
How do I test Cloudflare changes without confusing browser cache?
Use a private browser session and command-line HTTPS checks against the canonical hostname, then inspect Apache and Cloudflare logs for the same request. Test origin TLS and redirects before changing DNS proxy status so each layer has one clear failure boundary.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsQuick Recap
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.

