We recently changed the way you access GIT on all of our servers and have also now added wp-cli to all of our servers which makes it easy to setup WordPress Staging and recovery for your WordPress site. To set this up we will use VersionPress which is really an amazing plugin that is extremely well done and efficient.
Install VersionPress For Easy WordPress Staging
Unfortunately downloading and extracting through SSH does not create a clean install as some symbolic linking fails. Installing through WordPress admin remedies this so go ahead and download VersionPress than upload, install, and activate.
You should see it activate successfully. Now in your WordPress admin you will see:
Go ahead and activate it. If it complains about GIT version there are 2 options to fix it.
- Change GIT Version With Alias
- Add the following to your to your wp-config.php:
define('VP_GIT_BINARY', '/usr/local/cpanel/3rdparty/bin/git');
I will use option #2.
nano /public_html/wp/wp-config.php
Now you should be able to proceed with activation after refreshing the page in your WordPress admin area.
Create A Staging Site
Make sure you are in your site directory and issue the command:
wp vp clone --name=staging
You now have a staging site called “staging”.
This creates a full clone including all files, a database, and makes the needed changes to wp-config.php.
Let’s Have Some Fun!
Now to test things out change the theme on your staging site, and create a few posts and or pages on the “live” environment. When ready issue the command:
wp vp pull --from=staging
VersionPress will compare the changes and merge them properly on your live environment, how slick is that. If by chance something does go wrong you can instantly RollBack individual changes or do a complete RollBack to the point before you merged. Such an amazing way to setup a staging environment, and I have just barely touched the surface of what is possible with the combination of VersionPress, wp-cli, and GIT.
Keep in mind that VersionPress is still in development so always have your backups handy just in case (should you forget we have your back), though in my testing it has done its job extremely well and the only real thing I see lacking right now is plugin support. But this is something being worked on by the VP developers and it is expected to have extensive coverage of plugins by end of 2017.
Try this out on our premium Managed WordPress Hosting!
Mark says
Does this works in WP network multisite? And if we want to clone to a diferent server?
Chuck says
Hi Mark,
There is no multisite support yet but it is on the Roadmap.
For remote cloning, merging, etc it is not available out of the box, but from what I hear they are close to releasing something for this in an upcoming version. It can be done now but requires some work and manual setup:
https://blog.versionpress.net/2016/11/remote-workflows/
Robert says
As long as you always “pull” to a server (use: wp vp pull –from=), the sites can be setup anywhere. If you “push”, you will have to run the “wp vp apply-changes” command manually on the remote server or setup a post-receive hook to do it automatically.
Chuck says
That’s great, thanks for the info Robert!