This is the basic approach our team uses for managing multiple environments (development, staging, and production) when creating Wordpress websites.
Using this setup allows us to not have to worry about changing configuration settings every time we deploy a Wordpress site to a new environment.
The wp-config.php
file determines the environment automatically based on the following criteria:
Development
Matches any domain name containing:
.local
(i.eblend88.local
)local.
(i.elocal.blend88.com
)dev.
(i.edev.blend88.com
)localhost
(i.elocalhost
)xip.io
(i.eexample.local.192.168.0.1.xip.io
)
Staging
Matches any domain name containing:
staging.
(i.ewordpresssite.blend88-staging.com
orstaging.blend88.com
)
Production
Matches any domain name that doesn't satisfy the Development or Staging criteria.
To use this setup in one of your Wordpress websites:
- Copy the
config/
folder andwp-config.php
into your Wordpress root folder. - Edit each file in the
config/
folder with the MySQL database settings for each environment. - (Optionally) Change the environment URL matching in
wp-config.php
to work with whatever naming convention you may use in your workflow.