Cpanel staging with wordpress subdomain multisite

Hi,

When I use cpanels staging feature it copies a web app to a subdomain so I can make changes and merge it back in after.

It copies the site to a subdomain which means all the subsites end up pointing to their live versions and not the staging version.

Is there any way to fix this? Can I make a sub-sub domain?

For example site starts out: example.com
Then staging copy made: staging.example.com
Then subsite paths updated: subsite.staging.example.com

Anytime I have tried moving multisite it has been a real pain with all the database references. Is there a simple way to use a staging server with wordpress multisite?

  • Jude

    Hi there @Mike

    Hope you are doing great !!

    Is there any way to fix this? Can I make a sub-sub domain?

    I am not sure if this is possible with a one click soulution like what cpanel offers. There are longer ways of doing this like shown here but you must already be aware of them.

    Why not use a version control system for this. You can switch between branches and the live site will always have the stable version while you can stage as many as you want and creating and deleting stages as you require.

    See this for more info
    https://davidwinter.me/install-and-manage-wordpress-with-git/

    Once you set it up it becomes a breeze to stage.

    Cheers
    Jude

  • Mike

    Thanks for the reply Jude. The problem I had with search & replace method was that once I have several plugins and lots of data it was a bit problematic and would make random bugs where data had been stored in a difficult to search format. I think this is just because it is putting staging server to subdomain so it is not a straight swap. I was hoping to get something nice and easy to stage/repo/merge/rollback with just a click but it seems subdomain multisite wont allow for that easily.

    What I have got so far is that I click stage in cpanel then click repo. I then SSH in and do a mysql dump and add to repo. Then I push it to privtae git repo. I got the VVV vagrant box and I modified the provision script to download my github repo and import the database with wp-cli. I did the standard search & replace through wp-cli but ended up having to use https://github.com/interconnectit/Search-Replace-DB. I did a straight swap for full url but it doesn't work as all the subdomain values stored in various ways. I came up with a regex to replace and it worked but was random bugs still where it wasn't perfect. It was nothing big I just don't want to keep passing back and forth like this as it's so easy to miss something and then all my data ends up in the toilet.

    Michelle suggested a plugin that might work (https://wordpress.org/plugins/search-and-replace/) so will have a look at how they do it so I can pull it out to a script to run on provisioning.

    Managing search and replace for the staging & local is a bit tricky but doable I guess. I guess if I dry run all the changes then add the dry run output to the repo that will help. I think If I point a different domain at the staging folder on server then this will make my regex work better and be simpler.

    Thanks for the advice, I'll have a play around and see what works.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.