Skip to content

Instantly share code, notes, and snippets.

@ryanjbonnell
Created November 7, 2013 16:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanjbonnell/7357690 to your computer and use it in GitHub Desktop.
Save ryanjbonnell/7357690 to your computer and use it in GitHub Desktop.
WordPress Configuration for Multiple Environments
<?php
// Define Environment Variables
$environment = new stdClass();
$environment->local = '/wp-config-local.php';
$environment->staging = '/wp-config-staging.php';
$environment->testing = '/wp-config-testing.php';
// Dynamically Set Environment Constants
define( 'WP_ENV_LOCAL', file_exists( ABSPATH . $environment->local ) );
define( 'WP_ENV_STAGING', file_exists( ABSPATH . $environment->staging ) );
define( 'WP_ENV_TESTING', file_exists( ABSPATH . $environment->testing ) );
if ( WP_ENV_LOCAL ) {
require( ABSPATH . $environment->local );
} elseif ( WP_ENV_STAGING ) {
require( ABSPATH . $environment->staging );
} elseif ( WP_ENV_TESTING ) {
require( ABSPATH . $environment->testing );
} else {
define( 'DISALLOW_FILE_EDIT', true );
define( 'DISALLOW_FILE_MODS', true );
// Production Environment
$mysql_hostname = '';
$mysql_username = '';
$mysql_password = '';
$mysql_database = '';
}
// Configure MySQL Database Settings
define( 'DB_USER', $mysql_username );
define( 'DB_PASSWORD', $mysql_password );
define( 'DB_NAME', $mysql_database );
define( 'DB_HOST', $mysql_hostname );
define( 'DB_CHARSET', 'utf8' );
define( 'DB_COLLATE', '' );
$table_prefix = 'wp_';
// WordPress Security Keys
// http://codex.wordpress.org/Editing_wp-config.php#Security_Keys
define( 'AUTH_KEY', 'put your unique phrase here' );
define( 'SECURE_AUTH_KEY', 'put your unique phrase here' );
define( 'LOGGED_IN_KEY', 'put your unique phrase here' );
define( 'NONCE_KEY', 'put your unique phrase here' );
define( 'AUTH_SALT', 'put your unique phrase here' );
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
define( 'LOGGED_IN_SALT', 'put your unique phrase here' );
define( 'NONCE_SALT', 'put your unique phrase here' );
// Wordpress Application Options + Settings
// http://codex.wordpress.org/Editing_wp-config.php
define( 'WP_HOME', 'http://' . $_SERVER['SERVER_NAME'] );
define( 'WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME'] );
define( 'AUTOSAVE_INTERVAL', 300 );
define( 'WP_POST_REVISIONS', false );
define( 'WP_CACHE', true );
define( 'WP_MEMORY_LIMIT', '128M' );
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', dirname( __FILE__ ) . '/' );
}
define( 'ABSPATH', dirname(__FILE__) . '/' );
require_once( ABSPATH . 'wp-settings.php' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment