How to fix Ubuntu PHP Uncaught Error: Call to undefined function simplexml_load_file()

Problem:

Your wordpress page or other PHP application displays a critical error, with the following message:

2022/09/17 04:11:49 [error] 98082#98082: *1053 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to undefined function simplexml_load_file() in /var/sites/mysite.com/wp-content/plugins/otgs-installer-plugin/vendor/otgs/installer/includes/class-wp-installer.php:870

Solution

Install the php[VERSION]-xml package for the PHP version that is running wordpress.

For example:

sudo apt -y install php8.1-xml