Solution:
Whenever I’ve experienced this error it’s been because I didn’t have the correct php modules installed on the server.
What I did which fixed it was install these two php packages:
sudo apt install php-xml
sudo apt install php-xmlrpc
sudo systemctl restart apache2
While it sounds like that might not have been your problem, it’s likely to be the problem for other people who find this post by searching for the error message.