1

We are currently hosting a WordPress website at GoDaddy from the US that ultimately needs to serve customers in both China and the rest of the world.

For performance and security reasons we require to host both a .cn website from within China and a .com website from outside of China (the .cn and .com websites will be identical).

The .cn and .com websites have to be synchronised at all times and maintainable by a single WP Dashboard.

I believe that WP Multisite would not work here since the content would still be blocked by the Chinese Firewall when hosted from outside of China. And when hosted from within China would make access from outside of China too slow. Hence, the multi-domain multi-server installation required.

My question is whether such an architecture for WP exists and if there are any common/best practices for serving a multi-domain multi-server website?


I can think of one complication, the resources and links stored in the database contain the .com domain, this will make migration to a multi-domain website hard.

2
  • Off the top of my head, I am aware of plugins whose job it is to sync posts between installs. Perhaps a two-nstalls-with-sync'd-content approach might work for you. Sort of a CDN, after a fasion. Commented Jan 10, 2021 at 6:14
  • You've got two problems: you need to get data between two sites with a firewall in the middle that you're saying blocks some content, and you need to keep two Wordpress installations in bidirectional sync. I think a reasonable answer to this question involves you specifying exactly that the parameters of the former are: exactly what data can you transfer, and how? Once this is specified you'll get a more specific and useful answer
    – mozboz
    Commented Jan 20, 2021 at 18:33

1 Answer 1

3

The simplest way to create identical websites on different domains is to use the plugin Multiple Domain. This allows you to have a single WP install with one database serving two domains.

Next step is to copy this DB to a Chinese server, where create a script to copy DB and files from the main server outside of China. It should contain something as follows:

  echo -e "\nSyncing database..."
  ssh -i "$KEY_FILE" "$REMOTE_DOMAIN" "cd $REMOTE_PATH > /dev/null&&/user/bin/wp db export /tmp/wp.sql > /dev/null"
  scp -i "$KEY_FILE" $REMOTE_DOMAIN:/tmp/wp.sql wp.sql
  ssh -i "$KEY_FILE" $REMOTE_DOMAIN "rm /tmp/wp.sql"
  echo -e "Done."

  echo -e "\nImporting database..."
  wp --allow-root --quiet db import wp.sql
  echo -e "Done."

  rm wp.sql

  echo -e "\nSyncing uploads..."
  rsync -ase "ssh -i $KEY_FILE" --exclude "*backwpup*/*" $REMOTE_DOMAIN:"$REMOTE_PATH"/wp-content/uploads/* "$LOCAL_PATH"/wp-content/uploads
  echo -e "Done."

This script can be executed by cron every 5 min, for instance.

4
  • I'd forgo using a plugin and instead run redirects at the server level. FlyWheel Hosting's set up (NGINX) allows you to assign multiple domains to a single site, so it clearly can be done at the server level without having to modify what's in the DB. You would just have to replicate that process on both of your servers to route users correctly and KAGG's solution for the DB should work. KAGG, do you think something similar could be done but to only copy over changed or new content/data? Commented Jan 14, 2021 at 16:18
  • Does this synchronise back the other way too? The question sounds like the two websites need to be synchronised but didn't specify a direction - therefore perhaps changes from the Chinese side should also be sync'd back?
    – mozboz
    Commented Jan 20, 2021 at 18:30
  • 1-way synchronisation is more than fine. Either from US to China or vice versa.
    – BARJ
    Commented Jan 21, 2021 at 10:34
  • If the answer was helpful, you can mark it as accepted by clicking on the checkmark beside the answer or vote for it by clicking on up arrow. This could help other user looking for an answer to a similar question. Commented Feb 5, 2021 at 9: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.