Trying changes on a WordPress staging site
Make a private copy of a WordPress site, try changes there, then push files or the database back to the live site.
A staging site is a private copy of a live WordPress site on its own subdomain, with its own database. Try a new theme or plugin there, then push the result to the live site. Each live site can have one staging copy.
Creating a staging site
- Open the domain's WordPress tab and find the live site's card.
- In its Staging box, keep the Address
stagingor type another name. It becomesstaging.example.com. - Press Create staging site.
Hostctl creates the subdomain and a database, copies the files and the database, and changes the copy's address to the staging one. The box shows Copying… until it's done. Sites over 5 GB can't be copied.
If the first copy fails, everything it created is removed again. One
cause is a wp-config.php that doesn't set the database in the usual way.
Signing in to the staging site
Staging is Password-protected by default, so the browser asks for a name
and password before showing anything. The name is staging; the password is
next to it in the Staging box, with Copy. Then sign in to WordPress
with the same accounts as the live site, since the users were copied too.
Untick Password-protected to let anyone with the address see it.
Why search engines don't see it
Even without the password, staging stays out of search results. Every page carries a "noindex, nofollow" header, and WordPress's own "discourage search engines" setting is on. Staging sites also get no automatic updates and no security alert emails.
Staging runs on plain HTTP
A subdomain gets HTTPS only from a wildcard certificate, so on most domains
the staging site is http://staging.example.com. Its staging password and
your WordPress sign-in then cross the internet unencrypted, so avoid public
Wi-Fi while you use it.
To use HTTPS, request a wildcard certificate on the domain's SSL tab (see
Covering every subdomain at once).
Then press Refresh from live so the staging copy takes its https://
address.
Pushing changes to the live site
On the live site's card, open Push staging to live and choose what to send:
- Files (ticked by default): WordPress itself, plugins and themes. Live
ends up with exactly staging's set, so something removed on staging is
removed on live. New uploads are added; live uploads are never deleted.
wp-config.phpisn't touched. - Database: replaces the live site's posts, users, orders and settings with staging's. Live keeps its own address, its Visible to search engines setting and its maintenance mode.
Pushing the database loses anything added on live since the staging copy was made: new posts, comments, orders and users. Use Files alone when you only changed plugins or the theme.
Press Push to live. Hostctl saves a restore point of the live site first, pushes, then checks that the live site still loads. If it doesn't, the push is undone automatically.
A site with more than 2 GB of files (not counting uploads) or a database over 2 GB is too large for that restore point, so it can't be pushed.
Undoing a push
The push appears under Activity with Roll back. Choose Files only, keep the current database or Files and database, as for an update (see Rolling back an update). Rolling back leaves in place any uploads the push added.
If the live site looks very different after a push, it's flagged like an update, with Looks fine and Roll back. Check the pictures: a changed home page is often what you meant to push.
Starting again or removing staging
- Refresh from live replaces staging's files and database with a fresh copy of the live site. Changes made on staging are lost.
- Delete removes the staging site, its files, its database and its subdomain.