Piwik/Matomo Backend doesn't load on fresh install, lots of random JavaScript errors


(BlopTechnologies) #1

Hello,
I tried several times installing Matomo on my VPS, but the backend doesn’t load, there are always jQuery errors “$ is not defined” appears at least 3 times, and others (missing “}”, missing “:”, whatever) appear randomly. I am using Nginx but I am a newbie on this webserver. Can you help please ? It probably has to do with some fastcgi permissions or PHP fpm sockets but I don’t get how it has to be done.

The URL is https://www.stats.[mysite].net and here is the block in my sites-available conf file:

location ~ .php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/var/run/php7.0-fpm-[mysite].sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

Thanks in advance


(Lukas Winkler) #2

Hi,

Before trying something complicated with the server config, let’s check if it isn’t something simpler:

Are you using any adblocker? They often block all JS files on domains including piwik, so disabling it on your Matomo backend may help.
If it doesn’t help, you can check the network tab of the browsers developer tools and check why the JS file didn’t load.


(BlopTechnologies) #3

Thanks for the quick answer ! I had my website already whitelisted on uBlock origin. Also tried with uBlock uninstalled but no differences.

There are no JS files which “don’t load”, no 404’s in Network panel, only parse errors in Console panel.
The first JS error I see in console is:

“SyntaxError: missing } after function body” - index.php:14:50693
note: { opened at line 14, column 50596 - index.php:14:50596

and when I open this index.php in source mode it is a JS file with following URL:
https:// stats.[mysite].net/index.php?module=Proxy&action=getCoreJs&cb=[some big chain]

Line 1 of this file is: /* Matomo Javascript - cb=[the same big chain]*/
and line 14 is some minified version of jQuery UI.


(Lukas Winkler) #4

Hm, that sounds odd. This JS file is the minified sum of all Matomo JS files. Can you try deleting everything inside the tmp/ folder?
This way it will get regenerated.


(BlopTechnologies) #5

Still the same problem. I tried checking in Nginx error.log and the following error pops up when loading Matomo backend. Perhaps it is related ?

2018/02/22 15:35:56 [crit] 11284#11284: *538 open() “/var/lib/nginx/fastcgi/1/08/0000000081” failed (13: Permission denied) while reading upstream, client: [my IP], server: stats.[mysite].net, request: “GET /index.php?module=Proxy&action=getCoreJs&cb=[a big chain] HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php7.0-fpm-[mysite].sock:”, host: “stats.[mysite].net”, referrer: “https://stats.[mysite].net/index.php?module=CoreHome&action=index&idSite=1&period=day&date=yesterday”

The php7.0-fpm-[mysite].sock is used on my other sites on the same VPS and generally works well.


(Lukas Winkler) #6

Hi,

That’s really an odd issue.
Can you check who is the owner of /var/lib/nginx/fastcgi/? If it isn’t your webserver (www-data or similar), you’ll probably need to find out why and change it.

What I have seen, this folder is used by nginx to buffer large requests before sending them to the browser. As the JS file is quite large and comes from PHP, nginx tries to buffer the file, but as it can’t write to this directory, only a part of it is sent to the browser and JS is missing some parts and therefore throws errors.


(BlopTechnologies) #7

Problem solved !

I might have made a weird configuration with users on my VPS, because the web user - which was in the group www-data, was not “www-data” itself but another user also used as FTP user, so it had no r+w+x access on the /var/lib/nginx/fastcgi folder.

So I solved it by allowing group access to the fastcgi folder, for www-data group. Not sure if it’s secure though.

But anyway the Matomo-related part of the issue is solved, so thanks for the support !