Simple development / production configuration management in WordPress

I’ve seen a few posts about managing multiple WordPress configuration files in dev / prod environments. (Such as this one.) Many of them seem a bit over-engineered, so why make it more complicated than it has to be? Here is probably the fastest way to setup different configuration files for development and production environments in WordPress:

  • Copy wp-config.php twice, as and
  • Create a new wp-config.php file, input the snippet below:


/* Config loading based on environment variable */
if(getenv('WP_ENV') === 'dev')
    include '';
    include '';
  • In your VirtualHost configuration, set the appropriate environmental variable.


SetEnv WP_ENV   dev


SetEnv WP_ENV   prod
  • You’re done!

1 thought on “Simple development / production configuration management in WordPress

  1. JD

    Awesome post!

    I just started custom developing my own WordPress themes, this is super helpful. Bookmarked :)


Leave a Reply

Your email address will not be published. Required fields are marked *

Markdown is allowed in comments.