A normal best practice for any software development is to use a development environment rather than doing development straight into a production environment. Minor updates to a WordPress environment can be made easily without creating a development environment, but more major development should be done within a development environment, before being migrated across to production.
Many web hosting contracts enable clients to create subdomains as part of the hosting contract. You can also install an independent installation of WordPress into that subdomain environment. So that is a free way of creating a development environment. Following are the steps used for that process.
Creating the development environment
- Log into your hosting provider’s cPanel, find the Domains section and add a subdomain
- Go to the software installer in cPanel and install WordPress
- If your domain is with a different domain name provider (e.g. Cloudflare) then log into that provider, go to the settings for the domain, and add a DNS A record for the subdomain
- Log into the subdomain as the WP administrator and setup the plugins, and then do the development project. If you are making changes to the existing environment then you might choose to restore the top-level domain to the subdomain and then build on that. Alternatively you may need to build from scratch.
Migrating the website to production
- Use Updraft Plus to back up the dev environment – I recommend using Google Drive
- Login to the top-level domain as the WP Administrator
- Ensure that Updraft Plus is installed and is using the same remote storage location as the dev environment
- Within Updraft Plus, rescan the remote storage for the backups. This should pickup the backups of the dev environment
- Choose the relevant backup of the dev environment and do a restore. Updraft Plus will migrate the URLs of the media, pages, posts, etc from the subdomain to the top-level domain as part of the restore
- You will then be logged out and you have to login again as the Administrator – this is the WP administrator for the dev environment (users are overwritten as part of the restore). I generally ensure that the login for the Administrator of both the dev and production environments are the same, as that reduces confusion
- Review and cleanup the installation name in General Settings, etc.
Removing the development environment
- Go into cPanel and uninstall WordPress
- Within cPanel, delete the subdomain
- Within cPanel, go into file manager and delete and files and folders for the subdomain
- If your domain is with a different domain name provider (e.g. Cloudflare) then log into that provider go to the settings for the domain, and delete the DNS A record for the subdomain