This error can usually be resolved by executing the commands shown in the error message in the Matomo UI, for example:

If your web server username is www-data then you can have your webserver own the files in this directory (replace www-data by the web server username, sometimes called apache):

sudo chown -R www-data:www-data /path/to/matomo/*

If your server is running CentOS, SELinux or Redhat Enterprise Linux (RHEL), you may be able to fix the issue with the following commands:

chcon -R -t httpd_sys_rw_content_t /path/to/matomo
semanage fcontext -a -t httpd_sys_rw_content_t "/path/to/matomo(/.*)?"

(Replace /path/to/matomo with the path to the Matomo directory)