wp-config.php

The wp-config.php file is one of the most critical core files in any WordPress installation. It contains configuration settings for connecting to the database, defining WordPress constants, enabling debugging, and customizing performance or security-related behavior.

Location

  • Located in the root directory of your WordPress installation:
    public_html/wp-config.php or /var/www/html/wp-config.php
  • It’s created during the installation process or can be manually configured.

What Does It Do?

wp-config.php sets up:

  • Database connection (name, user, password, host)
  • Table prefix
  • Security keys and salts
  • Debugging mode
  • Custom constants and overrides

Useful Constants

ConstantPurpose
WP_DEBUGEnable/disable debugging
WP_MEMORY_LIMITSet max memory for WordPress
WP_CACHEEnable caching
FORCE_SSL_ADMINForce HTTPS in admin
DISALLOW_FILE_EDITDisable file editing via admin
AUTOSAVE_INTERVALSet autosave frequency
WP_POST_REVISIONSLimit or disable post revisions

Security Tips

  • Never leave this file writable (chmod 440 or 400 is ideal)
  • Move it one directory above the WordPress root for added security (WordPress can still find it)
  • Do not share it or upload to public repositories