The wp-config.php file is one of the most critical components of any WordPress installation. Often referred to as the "heart" or "brain" of a site, this file contains the foundational settings that allow your website to communicate with its database and function properly.
Because it stores sensitive information like database credentials and security keys, understanding how to manage, edit, and secure it is essential for every site owner. What is the wp-config.php File?
The wp-config.php file is a core configuration file located in the root directory of your WordPress file system. Unlike other core files, it is not included in the standard WordPress download package by default; instead, it is generated during the installation process based on information you provide.
If you download WordPress manually, you will see a file named wp-config-sample.php. During installation, WordPress uses this sample to create your actual configuration file. Core Components of wp-config.php wp config.php
The file is structured using PHP constants. The most common sections include: Editing wp-config.php – Advanced Administration Handbook
If you get "Fatal Error: Allowed memory size exhausted," try increasing the limit:
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_POST_REVISIONS', false );
// Or limit to 3 revisions:
define( 'WP_POST_REVISIONS', 3 );
If a plugin crashes the site due to a lack of memory, limits can be raised here. The wp-config
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
By default, admins can edit theme and plugin files in the dashboard. If a hacker gains admin access, they use this to inject malware. Disable it:
define( 'DISALLOW_FILE_EDIT', true );
wp-config.phpwp-config.php file to prevent unauthorized access.wp-config.php file with new security keys and settings.wp-config.php file in a secure location, such as a encrypted backup.Replace WordPress’s built-in scheduled tasks with a real server cron job for better performance:
define( 'DISABLE_WP_CRON', true );
Then set a server cron job to hit https://yoursite.com/wp-cron.php every 15 minutes. and user sessions.
define( 'AUTH_KEY'
These are long random strings that improve security for cookies, passwords, and user sessions.
define( 'AUTH_KEY', 'put unique phrase here' );
define( 'SECURE_AUTH_KEY', 'put unique phrase here' );
...
💡 Generate new salts instantly at: https://api.wordpress.org/secret-key/1.1/salt/