3rd June 2021

Matomo with Hiawatha

For this blog I use the Hiawatha web-server. I wanted to employ a web-analysis tool. For this I chose Matomo. Matomo was called Piwik previously. I already use GoAccess on which I have written in Using GoAccess with Hiawatha Web-Server.

To use Matomo with Hiawatha I had to do the following:

  1. Unzip the matomo.zip file downloaded from Matomo latest
  2. chown -R http:http the unzipped directory
  3. Edit index.php in the matomo directory and add umask(022) directly after <? at the top of the file

Editing index.php will result in below warning, which can be ignored:

Errors below may be due to a partial or failed upload of Matomo files.
--> Try to reupload all the Matomo files in BINARY mode. <--

File size mismatch: /srv/http/matomo/index.php (expected length: 712, found: 724)

Point 3 clearly is non-obvious. First I didn't get any further with the installation of Matomo, as Matomo could not create directories. Even when I tried to chmod the directories properly, the new directory had wrong permission and no sub-directories could be created. To verifiy that it was indeed a specific Hiawatha problem with umask I ran:

        printf("umask() = %o\n", umask());
        printf("umask() = %o\n", umask(0));
        printf("umask() = %o\n", umask(0));

This confirmed:

umask() = 117
umask() = 117
umask() = 0

Now the question emerged, from where this silly umask came from. Looking at the source code showed that in hiawatha.c the code indeed sets the umask:

int run_webserver(t_settings *settings) {
    . . .
    /* Misc settings

Categories: web-server
Tags: ,
Author: Elmar Klausmeier