How to fix the error « Matomo is unable to write to some directories »?
This error can usually be resolved by executing the commands shown in the error message in the Matomo UI, for example:
For the server you use (Apache, Nginx, or Windows), please find the configuration file. See what « user name » the config file runs things as. You can discover this by searching the web server config file for « user » and « group ». In Apache servers, both of the following names are common: www-data
or apache
.
Then you can change the owner permission on all of your Matomo files, using whichever command below matches your server’s name.
sudo chown -R www-data:www-data /path/to/matomo/*
sudo chown -R apache:apache /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)
In case you try the above and are still having problems, here is a longer example, for a server named www-data (the most common name), which might help you also:
sudo chown -R www-data:www-data /var/www/html/matomo # I am assuming www-data is the server's name AND that the path to your matomo directory is /var/www/html/
sudo find /var/www/html/matomo/tmp -type f -exec chmod 644 {} \;
sudo find /var/www/html/matomo/tmp -type d -exec chmod 755 {} \;
sudo find /var/www/html/matomo/tmp/assets -type f -exec chmod 644 {} \;
sudo find /var/www/html/matomo/tmp/assets -type d -exec chmod 755 {} \;
sudo find /var/www/html/matomo/tmp/assets -type f -exec chmod 644 {} \;