Moodle 5.3 Public Directory Explained for Apache, Nginx and cPanel
All of our Moodle themes are now fully compatible with Moodle 5.3

Moodle 5.3 Public Directory Explained for Apache, Nginx and cPanel

Secure Moodle 5.3 server folder structure with the public directory highlighted

Quick answer: Moodle’s newer directory structure separates web-accessible files from configuration and internal code. In Moodle 5.3, the server document root should point to the installation’s public/ directory. Serving the repository root defeats the security design and often causes broken routing.

The intended layout

If the Moodle source is stored at /var/www/moodle, the website document root should be /var/www/moodle/public. The active config.php remains one level above public, and moodledata remains outside the web root entirely.

Apache approach

Update the VirtualHost DocumentRoot and corresponding Directory rule to the public path. Preserve HTTPS, rewrite and PHP handling. Reload configuration only after validating its syntax, then test the front page, login, static assets and CLI cron.

Nginx approach

Set the server root to the public directory and keep the PHP front-controller rules aligned with Moodle’s documentation. Do not add broad aliases that expose the parent repository. Validate the configuration and test 404 handling before production traffic.

Shared hosting and cPanel

The clean solution is changing the domain’s document root. If the provider does not allow that, ask about a symlink or a location-specific alias. Copying selected files into public_html creates a fragile upgrade path and should not be improvised without provider support.

Troubleshooting after the change

A 404 usually points to an incorrect root or rewrite rule; missing CSS can indicate a bad wwwroot, proxy or asset path. A 403 suggests permissions or Directory rules. Inspect web-server and PHP logs instead of repeatedly changing file permissions.

Related Moodle 5.3 guides

Frequently asked questions

Where should config.php be stored?

The active config.php belongs in the Moodle base directory, one level above public, not in the public web root.

Where should moodledata be stored?

Outside the web-accessible directory, with only the permissions required by the Moodle process.

Can I copy public files into public_html?

That can create an unreliable upgrade layout. Prefer changing the domain document root, a controlled symlink or a provider-supported alias.

When to bring in specialist help

Use an experienced Moodle administrator or hosting engineer when the work changes database major versions, authentication, production routing, custom plugins or a heavily modified theme. Record the change, test it away from production and keep a named rollback owner.

Final recommendation

Use a staging site, rely on version-specific evidence and keep a tested rollback path. Moodle 5.3 is a strong long-term target, but a controlled upgrade is more valuable than an early upgrade that breaks teaching workflows.

Source check: Verified on 21 October 2026 against official Moodle installation layout and official upgrade and directory restructure guidance.

Leave a Reply

Your email address will not be published. Required fields are marked *