When developing software, it’s important to have different environments so that modifications made by developers don’t affect others outside their own “sandbox” or the “production” server. Best practices generally dictate three tiers: a local development environment for each developer, a staging environment to integrate changes from multiple developers, and a production environment.
WordPress is one of the best blogging platforms available, but it isn’t really designed to be used in multiple environments. It isn’t too difficult to setup multiple environments, though. Configuration variables can be read in from environment variables that tell WordPress which environment it is in.
With Apache, add the environment variables to your .htaccess file:
SetEnv WP_DB your_database_name
SetEnv WP_USERNAME your_username
SetEnv WP_PASSWORD your_password
Then you can grab these settings in the WordPress configuration file, wp-config.php:
// The name of the database for WordPress
// MySQL database username
// MySQL database password
// For developers: WordPress debugging
// Override the wp_options and set the site
define('WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME']);
define('WP_HOME', 'http://' . $_SERVER['SERVER_NAME']);
You can also set these environment variables using nginx:
fastcgi_param WP_DB your_database;
fastcgi_param WP_USERNAME your_username;
fastcgi_param WP_PASSWORD your_password;
You probably also need to tell php to load your environment variables in php.ini:
variables_order = "EGPCS"
Now you can have multiple environments set up to use with your version control without any additional direct configuration of WordPress.