wp-config.php is where WordPress hardening starts because it runs before any plugin, before any theme, and before any database query. A vetted set of constants there fixes more attack surface in five minutes than a security plugin does in an hour.
What’s happening
WordPress reads wp-config.php early in wp-settings.php. Constants set there control debugging, file editing, automatic updates, salts, SSL handling, and more. Some constants only meaningfully exist if you define them — there is no UI surface — and they default to whatever WordPress core decides. Most of the defaults are friendly to a development laptop, not to production.
How to verify
Audit the current state:
wp config get DISALLOW_FILE_EDIT 2>/dev/null
wp config get DISALLOW_FILE_MODS 2>/dev/null
wp config get FORCE_SSL_ADMIN 2>/dev/null
wp config get WP_DEBUG 2>/dev/null
wp config get AUTOMATIC_UPDATER_DISABLED 2>/dev/null
grep -E "AUTH_KEY|SECURE_AUTH_KEY|LOGGED_IN_KEY" wp-config.php | head -3
Anything that returns empty means the constant is undefined, which means WordPress is using the default — usually the less restrictive one.
The fix
Apply these to wp-config.php between the salts block and the That's all, stop editing! line:
-
Disable in-admin file editing. Removes the Theme/Plugin editor under Appearance and Plugins:
define( 'DISALLOW_FILE_EDIT', true ); -
Disable plugin/theme installs and updates from the dashboard. Use when you deploy via WP-CLI or CI and want the GUI to stay read-only:
define( 'DISALLOW_FILE_MODS', true ); -
Force SSL for the admin area. Belt-and-braces protection if a redirect is misconfigured:
define( 'FORCE_SSL_ADMIN', true ); -
Quiet debug output in production while still logging:
define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', '/home/cpaneluser/logs/wp-debug.log' ); define( 'WP_DEBUG_DISPLAY', false ); @ini_set( 'display_errors', 0 ); -
Auto-update policy: minor versions of core only, no plugins or themes:
define( 'WP_AUTO_UPDATE_CORE', 'minor' ); define( 'AUTOMATIC_UPDATER_DISABLED', false ); -
Limit post revisions and empty trash quickly to keep
wp_postslean:define( 'WP_POST_REVISIONS', 5 ); define( 'EMPTY_TRASH_DAYS', 7 ); -
Memory limit for the admin specifically, since plugin updates and imports need more headroom than the front-end:
define( 'WP_MEMORY_LIMIT', '256M' ); define( 'WP_MAX_MEMORY_LIMIT', '512M' ); -
Disable WP-Cron via HTTP and run it from cPanel cron instead — fewer surprises under load:
define( 'DISABLE_WP_CRON', true );Then add a cPanel cron entry:
wget -q -O - https://example.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1every 5 minutes.
After editing, chmod 600 wp-config.php so only the cPanel user reads it. For environments where this configuration needs to stay consistent across many accounts, Stack Harbor manages it as part of cPanel and WHM management.
Stack Harbor operates production WordPress at scale — see Enterprise WordPress for the managed model, or book a WordPress consult for a written read of your current shape.