Matomo on CyberPanel

I successfully installed Matomo on CyberPanel, but cannot solve one last issue, cron. Installation is as:

cd /home/matomo.mydomain.com/matomo
wget https://builds.matomo.org/matomo-latest.zip && unzip matomo-latest.zip
cp -ar matomo/* .
rm -rf matomo-latest.zip 'How to install Matomo.html' matomo
chown -R cyberpanel:cyberpanel /home/matomo.mydomain.com/matomo
chmod -R 755 /home/matomo.mydomain.com/matomo

So, in ‘normal’ (GCP Marketplace deployment image), I have for /etc/cron.d/matomo-archive:

MAILTO="myemail@mydomain.com"
5 * * * * root /usr/bin/php /var/www/html/console core:archive --url=https://matomo.mydomain.com/matomo/ > /home/files/matomo-archive.log

and working

su root -s /bin/bash -c "/usr/bin/php /var/www/html/console core:archive --url=https://matomo.mydomain.com/matomo/"

On CyberPanel installation for /etc/cron.d/matomo-archive, I set:

MAILTO="myemail@mydomain.com"
5 * * * * root /usr/bin/php /home/matomo.mydomain.com/matomo/console core:archive --url=https://matomo.mydomain.com/matomo/ > /home/files/matomo-archive.log

but output is bad and cron actually not working (so, I have for):

su root -s /bin/bash -c "/usr/bin/php /home/matomo.mydomain.com/matomo/console core:archive --url=https://matomo.mydomain.com/matomo/"

output as

#!/usr/bin/env php

So, it looks that something is wrong with my paths (I guess to console).

Does anyone understand what I did wrong?

Hi,

I don’t know know cyberpanel, but couldn’t you just run sudo php /path/to/console core:archive --url= or something like this without explicitly calling bash?
Or better use sudo -u name-of-php-user ... to run archiving as the same user as you php on the webserver.
Of course this assumes your server is using sudo and depending on how Linux is set up, this might differ.

  1. Well, in relation with Matomo, CyberPanel has only two important points:
  • It is instead on Apache or Nginx, on LiteSpeed server.
  • Installation location is different. Instead of /var/www/html/, it is /home/mydomain.com/matomo/ (what in entire script only change console path).
  1. Your first idea simply NOT WORKING. For me is confusing simple fact that only installation path is ONLY changed part from code what works on Matomo GCP image installation and from CyberPanel manual installation. So, to be clear, I think that we can change whatever we want from original tutorial code, problem is somewhere else, not in code itself (only install path is changed). To say, maybe Matomo GCP image contain some additional OS package (of Debian), what is not part of CentOS installation image. However, Matomo not show indication of any kind of missing dependencies.

  2. Your second suggestion -> I have no idea how it should to looks with above changed installation location path.

Could you please be kind and write down full code for second suggestion?

P.S. - Sorry, I forgot to wrote, CyberPanel is installed on CentOS 8 Google Cloud Platform VM image.

Hi,

I have never used CentOS before, so I don’t know if sudo works there. (Or is intended to be used.
The second solution is exactly the same as the first one just with -u name-of-php-user added to not run the script as root.

Does it really just output #!/usr/bin/env php? I have no idea why php-cli would ever output the content of the script.

Thanks for effort. It was kind of the mess of many details, but mainly was problem with permissions. However, I found the way to install it in properr way. If here is anybody from Matomo and if there is any need to be posted kind of tutorial how to install Matomo on CyberPAnel, I’m available.