I have Wordpress site at /var/www/contoso/html (contoso.com) running on a CentOS 8 server. I would like to run a new theme and make some frontend changes to it to make it match the look and feel of the old theme. I imagine that using a staging instance is the way to go.

Is the proper approach to copy site files to /var/www/contoso-staging/html (dev.contoso.com) and use a copy of the database? Or would it be possible to simply create a read-only database user and use the production database?

Also, I'd like to use version control for this. Would I create a GitHub repo for the production site and another for the staging site? Once the changes are finalized in staging, what would be the proper way to copy them over to live site?

If you have any suggestions outside of this, or if I am not on the right track, please feel free to offer your thoughts.

Thank you.

  • "simply create a read-only database user and use the production database" - to browse the site yes I think so but you might have to jump through hoops to log into it. I think a copy would be simpler to work with.
    – Rup
    Jul 15, 2021 at 12:05
  • Version control of what - the theme? Yes, just like any other code. You can't easily version the database content and settings, although there are pay-for plugins that'll do that for you too.
    – Rup
    Jul 15, 2021 at 12:06
  • Yes, I meant version control of changes to theme files. I wanted to know how then the changes would be applied to the live site.
    – location
    Jul 15, 2021 at 13:34

1 Answer 1


Usually people don't create a repo for their entire site. Instead, they typically will create a repo for each theme and plugin.

So, you'll have a staging site where you can edit your theme (or child theme) files and keep those all in a repo. Once everything looks good on staging, you can then push from the repo to the live site. The trickiest part is usually dealing with the database, because there are many places WP will set the URL in the database, and some of these are serialized, meaning if you do a simple search and replace, you'll end up breaking the site. But if you're not doing much data work that has to be pushed back and forth between sites, usually the file push to git and then just pushing from git to both your staging site and your live site is typically a good way to version your code and test things before they go live.

You can get even more fancy and use Github Actions to automatically deploy to your live site, but it all depends on whether you need that level of automation or not.

  • So you mean, add the production and staging sites to GitHub at their root, meaning /var/www/html, then create a repo for each theme or plugin that needs to be customized? Or avoid setting up GitHub at the root of the site? I ask because a lot of guides that I came across add their sites at the root.
    – location
    Jul 21, 2021 at 17:56
  • Avoid setting up Git at the root of the site, and only set up Git within the theme folder itself. Likewise with any custom plugins - set up a separate Git repo within each individual plugin folder.
    – WebElaine
    Jul 21, 2021 at 20:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.