Setting up WordPress supporting Multi-Environment configurations
Setting up Multi-Environments via WordPress
WordPress doesn’t have built-in support for developers working in multiple environments, e.g local, staging, and production.
The process usually involves updating the database settings in wp-config.php and running a SQL change on the database to update the ‘wp_siteurl’ and ‘wp_home’ settings. Using multi-environment config you don’t need to edit your config files between environments or update site URLs in your database. The system detects what environment the current website is in and loads the relevant config file for that environment.
It splits the config files out into:
- wp-config.default.php – any shared settings used across all environments
- wp-config.environment.php – the settings for a specific environment
- wp-config.env.php – sets up which URLs work for which environments
- wp-config.php – the original WP config file which now contains loading code
The following repository contains standard config setup for WordPress, this supports multiple environments such as your local development copy, a test staging site, and the live production site.https://github.com/studio24/wordpress-multi-env-config