The Perfect WordPress wp-config.php

Issue: Standardizing the WordPress config, for use in multiple installations, and with settings that help improve operations.

Solution: Use the following code (below) as a drop-in for installations. Simply replace the code that contain “…XX…” with your valid code. And… Always generate new salt keys; by visiting: https://api.wordpress.org/secret-key/1.1/salt (never use the same keys across multiple installations).

Key settings include:

  • Turn on caching
  • Turn off file editing within WP
  • Turn off major core updates (but still allow incremental version updates)
  • Don’t allow cron to run “forever”
  • Hard code the website URLs (less database calls)
  • Ensure admin and logins are using SSL/https
  • Reduce database clutter, only keep one post revision
  • Only save post revisions every 10 minutes
  • Empty the trash every 15 days (reduce database clutter)
  • When images are changed, remove the old versions when new versions are uploaded
  • Keep the website safe, don’t allow copy and pasted html code (from other sources) to be pasted into posts or pages
<?php
define( 'WP_CACHE', true);
define( 'DB_NAME', 'XXXXXX_wpdb');
define( 'DB_USER', 'XXXXXX_wpus');
define( 'DB_PASSWORD', 'XXXXXXXXXXXXXXXXXX');
define( 'DB_HOST', 'localhost');
define( 'DB_CHARSET', 'utf8');
define( 'DB_COLLATE', 'utf8mb4_unicode_ci');
define( 'AUTH_KEY',         'fbA!>JhB+ISf~i4mz*y+`NM6>~lMVB*</krH#?]2A+y.5#q<>5?CMkDaLp%^%P$7');
define( 'SECURE_AUTH_KEY',  'E&8Y.90)u DfN5-,[email protected]?]M7#[email protected]}c`,GFdCZ:M[g_rJZZm8)KJ+)jt');
define( 'LOGGED_IN_KEY',    'OOm)97bTI1;Nj9!Sal;KQmhh|0}v|u_Y-F*/JV ;gq^-LCW&9sJ:T+AZ72^9i}.y');
define( 'NONCE_KEY',        '>T~r}w,2[B}s5wIs9}E4S}a#rSr;[email protected]&CuSiZ$:2KpK-h]0_;m)/4#X(q^]s-1o');
define( 'AUTH_SALT',        ')Qj]}Zy7|:T%^$hV_a&w%]@]pnjf%;cVhiH^[email protected];KV,&H sSb*#|t{H?z8+mW-w');
define( 'SECURE_AUTH_SALT', 'u1g9:<_o^F-OW-[|y6j<k~/F-wPL~+IJj4[vc}R4p(X#/!is4|{HMs:rOqN>k_6m');
define( 'LOGGED_IN_SALT',   't7D-vCUFXX^M52z-!n!E{,eUO0OY[V`mqKF`(/]I{`hy0L>$VLvGEl<mmh<H:Mh-');
define( 'NONCE_SALT',       '~&kZ!Js`BxP+hpr*GNFu:vag8xoD2-|[email protected];[email protected]@}-s*DwqP+<sLBoi,z^Q+k');
$table_prefix  = 'XX_';
define( 'WP_DEBUG', false);
define( 'WP_ALLOW_REPAIR', true);
define( 'DISALLOW_FILE_EDIT', true );
define( 'WP_AUTO_UPDATE_CORE', minor );
define( 'WP_CRON_LOCK_TIMEOUT', 600 );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_HOME', 'https://www.XXXXXX.com' );
define( 'WP_SITEURL', 'https://www.XXXXXX.com' );
define( 'COOKIE_DOMAIN', 'www.XXXXXX.com');
define( 'FORCE_SSL_LOGIN', true);
define( 'FORCE_SSL_ADMIN', true);
define( 'WP_ALLOW_MULTISITE', false);
define( 'WP_POST_REVISIONS', 1);
define( 'AUTOSAVE_INTERVAL', 600);
define( 'EMPTY_TRASH_DAYS', 15);
define( 'IMAGE_EDIT_OVERWRITE', true );
define( 'WP_CRON_LOCK_TIMEOUT', 300 );
define( 'DISALLOW_UNFILTERED_HTML', true );
/* That's all, stop editing! Happy publishing. */
 
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
    define( 'ABSPATH', dirname( __FILE__ ) . '/' );
}
 
/** Sets up WordPress vars and included files. */
require_once( ABSPATH . 'wp-settings.php' );

Note: Again, without question… You MUST change the salt keys.

Leave a comment

BlogLogistics