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 website from within China and a website from outside of China (the and websites will be identical).
The and 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 domain, this will make migration to a multi-domain website hard.
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 website from outside of China (the .cn and websites will be identical).
The .cn and 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 domain, this will make migration to a multi-domain website hard.
Share Improve this question asked Jan 10, 2021 at 4:41 BARJBARJ 613 bronze badges 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. – Matthew Brown aka Lord Matt 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
Reset to default 3The 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.