Skip to content
Skip to the article
In WordPress: 10 articles
WordPress

wp-config.php reference

The wp-config.php constants Avunu sets most often for cron, memory limits, debugging, and Redis object caching, with what each one does.

Updated
Applies to
  • WordPress 6.x
  • Redis Object Cache 2.x
Tags
  • wordpress
  • wp-config
  • caching
  • redis
Reading time
3 min

This is a quick reference for the wp-config.php constants Avunu sets on most sites. Add constants above the /* That's all, stop editing! */ line. Anything defined after it is too late for WordPress to read.

You can set any of them from the WordPress directory with wp config set <NAME> <VALUE>. Add --raw for booleans and numbers so they aren't written as strings.

Cron

define( 'DISABLE_WP_CRON', true );

Stops WordPress from running scheduled tasks during page loads. Only set this together with a server cron job, as described in WordPress Cron, or scheduled tasks stop running.

Memory Limits

define( 'WP_MEMORY_LIMIT', '256M' );     // Front end. WordPress default: 40M (64M on multisite).
define( 'WP_MAX_MEMORY_LIMIT', '512M' ); // wp-admin and other memory-hungry tasks. Default: 256M.

WordPress raises PHP's memory_limit to these values when it's lower. They can't exceed a hard limit set by the host, so if the value doesn't take effect, raise memory_limit in the PHP-FPM pool or php.ini instead. Check what WordPress sees under Tools > Site Health > Info > Server.

WooCommerce and page builders usually need at least 256M.

Debugging

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

See Debugging Snippets for the full set, safe log locations, and the WP-CLI equivalents.

Redis Object Cache

These constants configure the Redis Object Cache plugin. Define them before enabling the drop-in with wp redis enable.

Unix Socket (Same Server)

A Unix socket is faster than TCP when Redis runs on the same machine. Set the scheme and socket path. WP_REDIS_HOST and WP_REDIS_PORT aren't used for sockets.

define( 'WP_REDIS_SCHEME', 'unix' );
define( 'WP_REDIS_PATH', '/run/redis/redis.sock' );
define( 'WP_REDIS_PREFIX', 'example_com:' );

The socket path depends on the distribution and Redis config (unixsocket in redis.conf). Common locations are /run/redis/redis.sock and /var/run/redis/redis.sock. The PHP user needs permission to read and write the socket, usually by being in the redis group.

TCP (Local or Remote)

define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_REDIS_DATABASE', 0 );
define( 'WP_REDIS_PREFIX', 'example_com:' );

For a remote Redis server, use a private network address (for example in 10.0.0.0/24), require a password with WP_REDIS_PASSWORD, and never expose port 6379 to the internet.

Always Set a Prefix

Warning

When several sites share one Redis server, give each a unique, readable WP_REDIS_PREFIX. Without it, sites read each other's cached options and users. A cache flush empties the whole Redis database, so also give each site its own WP_REDIS_DATABASE (0–15) where possible. WP_REDIS_SELECTIVE_FLUSH limits flushes to the prefix instead, but it's much slower.

Note

Some hosting panels ship their own Redis cache plugin with a different constant prefix. Check the host's documentation rather than mixing two plugins' constants. Only one object cache drop-in can be active, so pick Redis Object Cache, the host's plugin, or Docket Cache, not several.

Check the connection after configuring:

wp redis status

Sources

This article is in the public domain (CC0 1.0), code samples included. Use it however helps you.