Last active
August 29, 2015 14:07
-
-
Save aubreypwd/63f8ba2bb8db495f5546 to your computer and use it in GitHub Desktop.
How to create a mobile, hackable, wp-config.php file for local, staging, and production environments (how I do it anyway).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
*/ | |
// Production | |
if( | |
$_SERVER['HTTP_HOST'] == 'example.com' | |
// Make sure and include circa 1994 | |
|| $_SERVER['HTTP_HOST'] == 'www.example.com' | |
) { | |
// ** MySQL settings - You can get this info from your web host ** // | |
/** The name of the database for WordPress */ | |
define('DB_NAME', 'example.com'); | |
/** MySQL database username */ | |
define('DB_USER', 'user'); | |
/** MySQL database password */ | |
define('DB_PASSWORD', 'password'); | |
/** MySQL hostname */ | |
define('DB_HOST', 'localhost'); | |
/** Database Charset to use in creating database tables. */ | |
define('DB_CHARSET', 'utf8'); | |
/** The Database Collate type. Don't change this if in doubt. */ | |
define('DB_COLLATE', ''); | |
/** | |
* 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. | |
*/ | |
define('WP_DEBUG', false); | |
// Just in case we copied this over, let's clear it out. | |
if( file_exists( 'robots.txt' ) ){ | |
file_put_contents( 'robots.txt', "" ); | |
} | |
} | |
// Staging | |
if( $_SERVER['HTTP_HOST'] == 'example.stagingdomain.com' ) { | |
// ** MySQL settings - You can get this info from your web host ** // | |
/** The name of the database for WordPress */ | |
define('DB_NAME', 'example.stagingdomain.com'); | |
/** MySQL database username */ | |
define('DB_USER', 'user'); | |
/** MySQL database password */ | |
define('DB_PASSWORD', 'password'); | |
/** MySQL hostname */ | |
define('DB_HOST', 'localhost'); | |
/** Database Charset to use in creating database tables. */ | |
define('DB_CHARSET', 'utf8'); | |
/** The Database Collate type. Don't change this if in doubt. */ | |
define('DB_COLLATE', ''); | |
/** | |
* 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. | |
*/ | |
define('WP_DEBUG', true); // Yes, let's even smash notices on staging. | |
// Keeps the Googlers away... | |
if( ! file_exists( 'robots.txt' ) ){ | |
file_put_contents( 'robots.txt', "User-agent: *\nDisallow: /" ); | |
} | |
} | |
// @aubreypwd's VVV Development | |
if( $_SERVER['HTTP_HOST'] == 'example.com.dev' ) { | |
// ** MySQL settings - You can get this info from your web host ** // | |
/** The name of the database for WordPress */ | |
define('DB_NAME', 'example.com.dev'); | |
/** MySQL database username */ | |
define('DB_USER', 'root'); | |
/** MySQL database password */ | |
define('DB_PASSWORD', 'root'); | |
/** MySQL hostname */ | |
define('DB_HOST', 'localhost'); | |
/** Database Charset to use in creating database tables. */ | |
define('DB_CHARSET', 'utf8'); | |
/** The Database Collate type. Don't change this if in doubt. */ | |
define('DB_COLLATE', ''); | |
/** | |
* 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. | |
*/ | |
define('WP_DEBUG', true); | |
// Just in case we copied this over, let's clear it out. | |
if( file_exists( 'robots.txt' ) ){ | |
file_put_contents( 'robots.txt', "" ); | |
} | |
} | |
/* No matter where you move your site to, the domains, URL's, etc will follow whatever domain it's on. */ | |
define( 'WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] ); | |
define( 'WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] ); | |
define( 'WP_PLUGIN_DIR', realpath( $_SERVER['DOCUMENT_ROOT'] . '/wp-content/plugins' ) ); | |
define( 'WP_PLUGIN_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/wp-content/plugins' ); | |
define( 'WP_THEMES_DIR', realpath( $_SERVER['DOCUMENT_ROOT'] . '/wp-content/themes' ) ); | |
define( 'WP_THEMES_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/wp-content/themes' ); | |
define( 'WP_CONTENT_DIR', realpath( $_SERVER['DOCUMENT_ROOT'] . '/wp-content' ) ); | |
define( 'WP_CONTENT_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/wp-content' ); | |
/**#@+ | |
* Authentication Unique Keys and Salts. | |
* | |
* Change these to different unique phrases! | |
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service} | |
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again. | |
* | |
* @since 2.6.0 | |
*/ | |
define('AUTH_KEY', '`&d|.pQF>n]@tOH%4zh>-]8[,ds>m>3s@|DVFR3+hf]=cv8E3=b-uq8kmD6O~-YW'); // Please change these. | |
define('SECURE_AUTH_KEY', '|IN0`k(4t<|Ah/Vs|_4$+{@MfM>j0v#oO%-Av02cKG;+nznO&$&{+iX`2Q]8pl|0'); | |
define('LOGGED_IN_KEY', 'IilYZndF|E|hEp+!A$v~?KBMCJFr/XK-wApq~x=H$z>wQRyX[.I]`7>cnpd4-w5P'); | |
define('NONCE_KEY', ':lD]$YHB/O^?)orWlsIv+6!8X9D8A|chM|0$uW/*wrOI6sdR@Z`I#VLAz!-[_tiX'); | |
define('AUTH_SALT', 'fDuVZY5gZcw>D=@E(3%M<IPdtQCdb?DK$gjOKj$j|5)m]_DtC6pxm$M?cX|U?K:T'); | |
define('SECURE_AUTH_SALT', 'ZTXr[ep-y*}o:c|>t9 0g^b?%[QcD%|<jp;+^,B=T(-t(#Tm]QS{.dX=$Z8)9gKF'); | |
define('LOGGED_IN_SALT', '~V><>Q1o!O$Bq1DsAHGcvd%kr/m(-<6(Nf`v&60rIfg3Ljxhx/sTs;&N*@qexp}g'); | |
define('NONCE_SALT', 'A>r;S!6JcnC-DTv4t@VYSs Ag|xXExZ58LH(2)3rP;Nk79lo-rqqpcQ02W!oW|-$'); | |
/**#@-*/ | |
/** | |
* WordPress Database Table prefix. | |
* | |
* You can have multiple installations in one database if you give each a unique | |
* prefix. Only numbers, letters, and underscores please! | |
*/ | |
$table_prefix = 'wp_'; //Yours is different. | |
/** | |
* WordPress Localized Language, defaults to English. | |
* | |
* Change this to localize WordPress. A corresponding MO file for the chosen | |
* language must be installed to wp-content/languages. For example, install | |
* de_DE.mo to wp-content/languages and set WPLANG to 'de_DE' to enable German | |
* language support. | |
*/ | |
define('WPLANG', ''); | |
/* That's all, stop editing! Happy blogging. */ | |
/** 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'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment