Why Moodle config.php hardening matters for a self-hosted site
Settings in config.php move key security controls out of the Moodle admin interface and into a file that the server controls. For a security or platform lead running Moodle in their own infrastructure, that matters because a compromised administrator account can change anything the admin UI allows, but cannot easily change a file owned and protected at the operating system level. The practical goal is to make high-impact changes, such as installing plugins from the web, altering executable paths or changing scheduled tasks, require a deliberate action by the people who manage the server rather than a few clicks by whoever holds an admin session.
This page covers five areas. It explains how to set an upgrade key so that the upgrade process cannot be started by an unauthorized person, how to disable installation of plugins through the web interface so that code only arrives through your change process, and how to lock executable paths such as the locations of PHP and other binaries so that they cannot be redirected. It then covers preventing changes to scheduled task configuration and forcing plugin settings from the file so that a site-wide value cannot be quietly overridden in the UI. Each control is paired with the operational consequences it creates for upgrades, plugin releases and day-to-day administration.
Exact setting names, their default values and their behavior differ between Moodle versions, so confirm each key against the Moodle documentation for the version you run before you change the file. Check the current configuration reference on the Moodle developer site and test changes on a staging copy, since a setting that blocks web-based plugin installs or changes how settings are read can affect your upgrade and patching routine. Record each setting you lock, the reason for it and the person who approves changes to config.php, because the file itself becomes the control point you will need to audit.
Which config.php locks to set and when each one fits
This table compares five config.php locks by the risk each one addresses, who feels it day to day, what breaks when it is set wrongly and whether it suits a public site or a private intranet. Read each row as a decision: the stricter the lock, the more change requests go through the operations team. Confirm exact config keys and their behavior in the Moodle documentation for your release before applying any of them.
| Setting category | What it protects against | Who it affects | What breaks if set wrongly | Fit for public site vs private intranet |
|---|---|---|---|---|
| Upgrade key | Someone with admin access running the upgrade script or upgrade screens without the operations team's approval | Site administrators and the operations team who run upgrades | Upgrades stall at a prompt nobody on the team holds, delaying security patches | Public site: set it. Private intranet: set it if upgrades go through change control |
| Disabling web-based plugin installs | Unreviewed code arriving through the admin interface, including a compromised administrator account | Site administrators and plugin developers who install through the browser | Plugin installs must move to a deployment pipeline, which adds work for small teams | Public site: strongly suited. Private intranet: suited where code moves through version control |
| Locking executable paths | Redirection of calls to antivirus, image or archive tools to an attacker-controlled binary | Operations team and anyone who maintains file scanning or media processing | Scanning or conversion features fail silently or report missing tools after a server change | Public site: set it, since uploads are exposed. Private intranet: set it with paths documented |
| Preventing changes to scheduled task settings | Edits that disable security-relevant tasks or change run schedules without a record | Operations team, and developers who rely on task timing | Tasks stop running or run too often, affecting notifications, cleanup and backups | Both: useful on either, provided the team agrees who may change task timing |
| Forcing plugin settings | Administrators changing a plugin setting that a security or integration policy depends on | Site administrators, and integration teams whose connectors depend on fixed values | Integrations fail when a forced value does not match what the connected system expects | Public site: suited for auth and upload settings. Private intranet: suited where policy is fixed by a central team |
How a config.php lock sits between admins, the file system and upgrades
The diagram starts with a site administrator trying to change a setting in the web interface. Moodle reads the value from config.php first, so a locked setting is refused or ignored and the change never reaches the database. The second path is the server operator, who edits config.php through source control and a deployment with a change record. The temporary branch covers a planned upgrade or plugin install: the lock is lifted for the work, then restored and checked afterwards.
Who can change a locked setting, and the upgrade branch that reverts it.
Why settings in the admin UI can drift away from the intended security baseline
Settings that live only in the Moodle admin UI are stored in the database, so any account with the matching capability can change them. That includes a site administrator account taken over by an attacker, which can switch on web plugin installation, change where executable paths point, or alter scheduled task behavior without leaving anything outside Moodle that shows the change. The same risk comes from ordinary troubleshooting. A colleague who turns a setting off to clear an error, meaning to restore it later, may forget, and nobody reviewing the site will know the baseline has moved. Admin UI changes are logged in Moodle's own logs, but those logs sit in the system being protected and are only as trustworthy as the account that reads them.
Settings in config.php are different because the file lives on the server, outside the browser session. Normally the operations team owns it, deploys it through the same tooling as the rest of the stack, and keeps it in version control. A change to a locked setting then needs a commit, a review and a deployment, and each step leaves a record that does not depend on Moodle. Before you lock anything, confirm who may edit config.php, where the authoritative copy is kept, and whether your deployment tooling overwrites manual edits on the next run. A lock that a pipeline silently reverts is a monitoring gap rather than a control.
Be clear about the limit. Anyone with shell access to the web server can still edit config.php, so these settings reduce accidental change and change made through the Moodle admin interface. They do not replace server access control. Restrict SSH and sudo, separate the accounts that deploy code from those that administer the site, and review file permissions on config.php. Confirm these points with your own operations team and your hosting setup before you rely on the file as a boundary.
Setting up config.php locks in a safe order
This sequence turns the config.php lock settings into a tested, documented control on a Moodle site, so each lock is confirmed to work and can be reversed when required maintenance needs it.
Record current admin UI and config.php state
Before changing anything, the Moodle administrator and the platform engineer export the current config.php file and note the values shown in the relevant admin pages, including plugin installation, executable paths, scheduled task settings and the settings of any plugin to be forced. Store the copy with the date and the Moodle version in use. The step is done when the team can compare a before and after view of every setting in scope, and the baseline is saved outside the live server.
Decide which locks this site needs
The security owner, the Moodle administrator and the operations lead agree in writing which controls apply to this site: the upgrade key, disabling web plugin installs, locking executable paths, preventing scheduled task changes and forcing specific plugin settings. Each choice is recorded with the reason and the person who accepts the trade-off. This step is complete when the list is approved and every item has a stated reason, so no lock is added only because it is listed in a guide.
Add the chosen settings to a staging config.php
An engineer adds only the approved settings to a copy of config.php on a staging environment that mirrors production's Moodle version, PHP version and web server layout. Each setting is written with its documented config key, and the file is checked for syntax errors before it is loaded. The step is done when the staging site starts without errors and the file differs from the baseline only by the approved lines.
Confirm the admin UI shows the locked state
With caches cleared, the administrator signs in to staging and opens each affected admin page. The check confirms that the locked fields display as set by config.php and cannot be changed from the browser, and that the settings persist after a cache purge. Any setting that still appears editable is traced back to its config key before moving on. The step closes when every locked field matches the file and the results are recorded in the test log.
Test the lock against an upgrade or plugin install
On staging, the team runs a Moodle minor upgrade or a test plugin installation to confirm that the locks do not block required maintenance. They note which step fails, if any, and confirm the controlled path works, such as a planned change to config.php followed by re-locking. This step is complete when a maintenance run finishes on staging with the locks in place, or when every blocked step has a documented workaround approved by the security owner.
Document the temporary unlock procedure
The team writes a short runbook for temporarily removing or changing a lock during planned maintenance. It names who may authorize the unlock, the exact config.php lines to edit, the cache purge and verification steps, and the step that reapplies the lock afterwards. The runbook is tested once on staging by someone other than its author. The step is done when the runbook has been walked through and the reapply check has been recorded.
Re-run the security overview report after the change
On staging, and then on production during the approved window, an administrator opens the security overview report and confirms that the findings tied to the locked settings reflect the intended state. Any finding that still flags a setting the team has deliberately locked is investigated and either fixed or explained in the change record. The step is complete when the report output is saved alongside the baseline and the team has signed off the differences.
Store config.php under change control with a named owner
The final step places the approved config.php in version control or a managed configuration repository, with a named owner who approves every future edit. Access to the file is limited to the roles that need it, and each change requires a ticket that links to the security report output and the test record. The step is done when the owner confirms in writing that changes will follow this process and the repository history contains the baseline and the approved version.
Risks that remain after config.php locks are in place
Locking settings in config.php narrows what an administrator can change through the web interface, but it does not remove every path to a change. The cards below cover the risks that stay open after the locks are set, and the checks that show whether they are being managed.
Server-level write access to config.php
Anyone who can write to the file on disk can undo every lock in this section, so file permissions are the real boundary. Restrict write access to the deployment account and the web server user that needs read access only. Monitor the file with a file integrity tool that alerts on hash changes, and keep a copy of the expected version under change control so a diff is easy to review.
A lock that blocks a needed patch
Locks such as disabling web plugin installs can stop a security update from being applied through the admin screen. Before each Moodle security release, list the locked settings and confirm the update path still works in a staging copy. Record any lock that must be lifted temporarily so the change is planned rather than improvised on a live site.
An unlock left in place
Teams often remove a lock for maintenance and forget to restore it, which leaves the site open to the same change it was protected from. Treat every unlock as a tracked change with an owner and a reversal step. Review the active config.php against the approved baseline after each maintenance window and confirm that temporary settings were reverted.
Forced plugin settings that break features
A forced setting in config.php overrides the value in the admin interface, so a plugin that depends on a changed value may stop working without a clear error. After any plugin update or Moodle upgrade, test the features that depend on forced values, such as authentication, uploads and scheduled jobs. Keep a short list of each forced setting and the feature it affects so support staff can find the cause quickly.
Scheduled task changes that operations need
Locking scheduled task settings protects against tampering, but operations still need to adjust timing for backups, reports and cleanup jobs. Agree in advance who may request a change, how it is tested and how the cron host records the schedule. Review task logs after each change to confirm the new timing ran as intended and did not overlap with heavy jobs.
A compromised deployment pipeline
A deployment pipeline with rights to the server can write a malicious config.php in a normal release, and the change may look routine. Limit pipeline credentials to the paths they need, require review for changes to config.php, and sign or hash release artifacts before deployment. Compare the deployed file against the reviewed version after each release, and rotate pipeline secrets on a set schedule.
How the config.php lock plan changes by hosting model
On a single server run by one team, config.php is usually edited directly on the host by a named administrator, and the team controls every path that reaches the file. Changes are made through a change ticket, tested on a non-production copy, and then applied during a planned window. Because one server holds the only copy, the main risk is drift between what the change record says and what the file contains, so the lock settings should be reviewed after each upgrade and each plugin install.
- Edit rights: Restrict write access to config.php to the administrator account and the deployment user, and keep the web server user read-only.
- Change control: Record each lock in version control or a configuration register, with the reason and the reviewer.
- Verification: Re-run the security overview report after editing, because it checks several of these settings.
- Backups: Keep a dated copy of config.php in a location the web server cannot serve.
- Upgrades: Confirm that the upgrade key and the executable path settings still match the new release's documentation before the upgrade starts.
Check that the team can name the single person who last changed config.php and when, because that is the record an auditor will ask for first.
In a clustered or load-balanced deployment, every web node reads its own copy of config.php, so the file must be identical on every node. A setting that differs on one node can make a locked control apply on some requests and not others, which is hard to spot in normal operation. Deployment should therefore push the same file from one source of truth, and the platform team should compare checksums across nodes as part of each release.
- Single source: Store config.php in the deployment repository or configuration management tool, and render it per environment only for values that must differ, such as database hosts.
- Consistency checks: Compare file hashes across all nodes after each deployment and alert on any mismatch.
- Path locks: Confirm that executable path settings point to binaries that exist at the same location on every node.
- Shared storage: Keep moodledata on shared storage with the same permissions everywhere, and confirm that the private path is not served from any node.
- Rollout order: Apply changes to one node, verify it, then roll to the rest, so a bad lock cannot take the whole cluster down at once.
Check that no node has been edited by hand, since a single hand edit is the most common reason the nodes disagree.
With managed hosting, the provider often controls the server, and the client may have no shell access or no direct access to config.php. In that case the lock plan becomes a contract and support question: which settings can the client request, which the provider sets by default, and which need a change ticket. Moodle's own managed options, MoodleCloud and Moodle Partners, differ in what they allow, so the details must come from each hosting agreement rather than from general assumptions.
- Access model: Ask whether the client receives file access, a staging copy, or only an admin interface.
- Request path: Agree in writing how lock changes are requested, approved and recorded, and how long the provider takes to apply them.
- Plugin installs: Confirm whether web plugin installs are enabled, and who approves a plugin before it reaches the site.
- Evidence: Ask the provider for the current config.php values, or an export of them, for your records.
- Responsibility split: Document which controls the provider runs, such as patching and backups, and which the client owns.
Confirm with the host, before signing, that the agreed locks can be set and kept in place through upgrades and provider maintenance.
What config.php locks change for upgrades and plugin maintenance
Locks in config.php change how upgrades and plugin maintenance run, so they belong in the upgrade plan rather than being treated as a one-time hardening task. If the site blocks web plugin installs or forces plugin settings, the upgrade and any plugin update must be done through the command line or by temporarily relaxing the lock, and that step needs a named owner. Plan a temporary unlock window before each major release. Moodle ships major releases in April and October and minor point releases every two months in February, April, June, August, October and December, so most sites will face several planned changes per year. Record which locks are on, which ones the upgrade needs, and who restores them afterward, and confirm the exact sequence in the release notes for the version you plan to run.
Before changing any configuration for a new release, check the PHP and database requirements in the target release notes. The Moodle 5.1 notes require 64-bit PHP 8.2 or later and list supported database versions, and the Moodle 5.3 notes raise the PHP floor to 8.3 and change the database versions, including PostgreSQL 17 and MariaDB 11.4. Those requirements also set the minimum starting version for an upgrade, so a site that is behind may need an intermediate step first. Confirm the PHP and database versions on your servers against the notes for your target release before touching config.php, because a lock that works on one version can block a step that the next version depends on.
The Moodle 5.1 change that the document root must point to the /public directory is a web server configuration matter, not a config.php setting, but it must be handled in the same change window. A site that changes its locks and its web server root at different times can end up with a broken upgrade or with private paths exposed while the root is half-moved. Ask whoever manages the web server to confirm the document root, the PHP version and the database connection before the upgrade, and check the release notes for the version you plan to run to see which of these steps apply to your site.
Questions buyers ask about hardening Moodle config.php
How much effort does a config.php hardening pass take?
The effort depends on how many settings need review, how many environments must match, how mature your change control is, and how many plugins are installed. A site with one production instance, a documented configuration and few plugins is a much smaller job than a multi-environment estate with several custom plugins and no change records. No duration is given here because the figure depends on your environment. Ask for the effort split in a written scope: discovery of current settings, the list of locks, testing on a staging copy, and handover of the baseline.
Can our internal team harden config.php on its own?
Yes, if someone on the team has shell access to the server, knows how Moodle reads config.php, and can test changes without breaking upgrades. The settings themselves are not complicated, but the risk is in the side effects: a lock that blocks a later plugin install, or an upgrade that fails because an executable path was locked to the wrong location. Teams that do it alone usually benefit from a second reviewer and a written baseline so the next administrator knows which settings were intentional.
What does the work need from our team?
Expect to provide four things: read access to the server and the current config.php, a staging copy of the production site that matches its version and plugins, a named owner who approves each lock, and a maintenance window for testing upgrades after the changes. The owner matters most. Without someone who can decide whether a locked path or disabled install is acceptable, changes stall or get reverted.
How do config.php locks interact with the security overview report?
Locks in config.php change what the security overview report can see and fix, so the report should be run before and after the changes. Some checks will pass once a setting is locked, and some may still flag an issue because the underlying value is set elsewhere. Read each finding against the lock it relates to, and record the reason for any finding you accept. The report is a checklist, not a sign-off, so it should not be the only evidence that the configuration is sound.
What should we do when a lock blocks a needed upgrade or plugin install?
Do not remove the lock on the production server first. Confirm which setting is blocking the work, decide whether the change is planned, and make the change on staging so you can see the full effect, including upgrade steps and plugin settings. Then apply it through your normal change control, with a record of who approved it and why. Once the work is done, restore the lock or update the baseline so the stricter setting returns. This keeps temporary relaxations from becoming permanent.
Can a partner produce a written baseline of our configuration?
A partner can document the baseline as part of a fixed-scope engagement, provided the scope is agreed in writing before work starts. DeployOpen plans, hardens, documents and supports self-hosted platforms in the client's own infrastructure, so the baseline would describe your actual settings, locks, paths and the reasons for each. Ask for the baseline to list every config.php setting reviewed, its value, its owner, the test that confirmed it, and the date it was last checked. It is not an audit report or certification.
What ongoing work follows the initial hardening pass?
The baseline needs maintenance after every upgrade, plugin install and change to the server. Each Moodle minor release can alter defaults, and new plugins may require settings that the lock file does not yet cover. Decide who reviews the baseline after each release and how often the security overview report is rerun. Ongoing support, upgrades and continuous testing are available as retainers, and the scope of that work should also be set in writing.
What to confirm in your Moodle version and hosting before you lock settings
Settings in config.php behave differently across Moodle releases, hosting setups and plugin sets, so the locks you plan need checking before they reach production. The four cards below cover what to verify on your own site, starting with the release you run.
Exact setting names for your release
Confirm the config.php key names, accepted values and default behavior in the Moodle documentation for the exact version you run. Setting names and their effect can change between releases, so a lock copied from an older guide may not do what you expect. Record the version you confirmed against, and repeat the check after every upgrade.
Moodle releasesWhether hosting allows file edits
Check whether your hosting provider lets you edit config.php on the server, control the web root and set file permissions. Some managed hosts restrict file access or deploy code from their own pipeline, which can overwrite or block your locks. Ask the provider in writing how config.php is deployed and who can change it.
PHP and database versions for your release
Compare your PHP and database versions with the requirements for your target release. The supplied requirements for Moodle 5.1 call for 64-bit PHP 8.2 or later and PostgreSQL 15, MySQL 8.4, MariaDB 10.11 or SQL Server 2017 or later. For Moodle 5.3 the requirements are 64-bit PHP 8.3 or later and PostgreSQL 17, MySQL 8.4, MariaDB 11.4 or SQL Server 2019 or later.
Moodle 5.3 notesConflicts with installed plugins
List every installed plugin and check whether any of them read or write the settings you plan to lock. A forced plugin setting can break a plugin that expects to save its own values, and a locked path can block a plugin that needs to store files. Test each plugin's admin pages after the locks are applied, and note any plugin that stops saving changes.
Testing locks on staging first
Confirm that your team can copy the production configuration, database and code to a staging site and apply the same locks there. Staging should use the same release, PHP version, database and plugin set as production so that results carry over. Ask who owns staging, how long a rebuild takes and how you would restore config.php if a lock blocks administrators.
How DeployOpen scopes and delivers Moodle config.php hardening
DeployOpen plans, implements and documents Moodle config.php hardening inside infrastructure you control, starting from a written scope that names each setting, file and server path. Work moves through scoping, a build in a staging copy, verification and a handover your administrators can run without us.
How we scope
- Review the current config.php, web server layout and who can edit server files today.
- Agree which locks, paths and plugin settings the written scope covers before work starts.
- Set out ongoing support as a retainer if you want upgrades and re-checks after plugin installs.
How we build
- Apply the upgrade key, web plugin install block and executable path locks in a staging copy first.
- Lock forced plugin settings and scheduled task changes, then record each value and its reason.
- Test admin pages, cron runs and plugin updates to confirm the locks behave as intended.
How we hand over
- Deliver a dated change record listing every config.php setting, its value and its owner.
- Provide a runbook for planned upgrades, including where the upgrade key is stored and who holds it.
- Walk your administrators through reverting a lock safely, so changes go through your change process.
How we support
- Re-check config.php after each Moodle minor release and before any major upgrade.
- Retest locks when new plugins or server changes could override a forced setting.
- Offer continuous testing and upgrade support under a retainer, scoped in writing with your team.

