Skip to content

Instantly share code, notes, and snippets.

@ryanjbonnell
Created November 7, 2013 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanjbonnell/7357623 to your computer and use it in GitHub Desktop.
Save ryanjbonnell/7357623 to your computer and use it in GitHub Desktop.
WordPress Configuration for Multiple Environments
<?php
// Dynamically Set Environment Variables
$server[] = $_SERVER['HTTP_HOST'];
$server[] = $_SERVER['LOCAL_NAME'];
$environment->local[] = 'example.dev';
$environment->staging[] = 'staging.example.com';
if ( array_intersect( $environment->local, $server ) ) {
// Local Development
$db_hostname = '127.0.0.1';
$db_username = 'username';
$db_password = 'password';
$db_database = 'database';
define( 'WP_DEBUG', true );
} elseif ( array_intersect( $environment->staging, $server ) ) {
// QA Staging
$db_hostname = 'localhost';
$db_username = 'username';
$db_password = 'password';
$db_database = 'database';
} else {
// Production Environment
$db_hostname = '';
$db_username = '';
$db_password = '';
$db_database = '';
}
// Configure MySQL Database Settings
define( 'DB_NAME', $db_database );
define( 'DB_USER', $db_username );
define( 'DB_PASSWORD', $db_password );
define( 'DB_HOST', $db_hostname );
define( 'DB_CHARSET', 'utf8' );
define( 'DB_COLLATE', '' );
// Wordpress Application Options + Settings
// http://codex.wordpress.org/Editing_wp-config.php
$table_prefix = 'wp_';
// 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' );
define( 'WP_MEMORY_LIMIT', '128M' );
define( 'AUTOSAVE_INTERVAL', 300 );
define( 'WP_POST_REVISIONS', false );
define( 'WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] );
define( 'WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] );
define( 'DISALLOW_FILE_EDIT', true );
define( 'DISALLOW_FILE_MODS', true );
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