Skip to content

Instantly share code, notes, and snippets.

@joemaller
Created July 6, 2012 15:40
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 joemaller/3060965 to your computer and use it in GitHub Desktop.
Save joemaller/3060965 to your computer and use it in GitHub Desktop.
Git-safe WordPress config
<?php
/**
* Make a copy of this file named wp-config-db.php
* wp-config-db SHOULD NOT be version controled, add it to gitignore
* Use this to store database access information so the main
* wp-config.php file can be modified and version controlled.
*/
/**
* Debug block, set WP_DEBUG to false to disable this on the live site
*/
define('WP_DEBUG', true);
if (WP_DEBUG) {
@ini_set('display_errors', true);
@ini_set('error_reporting', E_ALL | E_STRICT);
@ini_set('error_log', $_SERVER['DOCUMENT_ROOT'] . '/php_error.log');
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
define('SCRIPT_DEBUG', true);
}
/**
* WordPress Database settings
*/
define( 'DB_NAME', 'database_name_here' );
define( 'DB_USER', 'db_username_here' );
define( 'DB_PASSWORD', 'db_password_here' );
define( 'DB_HOST', 'localhost' );
<?php
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, WordPress Language, and ABSPATH. You can find more information
* by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
*
* This file is used by the wp-config.php creation script during the
* installation. You don't have to use the web site, you can just copy this file
* to "wp-config.php" and fill in the values.
*
* @package WordPress
*/
/**
* Pull in local database definitions from wp-config-db.php
*/
if ( file_exists( dirname(__FILE__) . '/wp-config-db.php' ) )
include( dirname(__FILE__) . '/wp-config-db.php' );
/**
* Point to a wp-content directory outside of the WordPress core hierarchy
*/
define('WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/wp-content');
define('WP_CONTENT_URL', 'http://' . $_SERVER['SERVER_NAME'] . '/wp-content');
/**
* Explicitly set WP_SITEURL so admin pages work correctly
*/
define('WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME'] . '/wordpress');
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
if (!defined('DB_NAME'))
define('DB_NAME', 'database_name_here');
/** MySQL database username */
if (!defined('DB_USER'))
define('DB_USER', 'username_here');
/** MySQL database password */
if (!defined('DB_PASSWORD'))
define('DB_PASSWORD', 'password_here');
/** MySQL hostname */
if (!defined('DB_HOST'))
define('DB_HOST', 'localhost');
// [...]
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*/
// moved to wp-config-db.php for portability.
// define('WP_DEBUG', false);
@joemaller
Copy link
Author

Dumbed down the include call to use dirname(__FILE__) instead ofDIR` for compatibility with older versions of PHP. Also expanded the debug section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment