Posted on Leave a comment

DIY Analytics – Matomo Install for WordPress

Get the latest Matomo ( Piwik ) code

wget https://builds.matomo.org/matomo-latest.zip

Place this file into your Apache2 httpd “Document” directory and unzip/untar

unzip matomo-latest.zip

Set permission to the owner of the httpd process ( www-data in my case )

chmod -R www-data:www-data matomo

Check the permissions

ls -l 

Make it accessable

I like to just place a symbolic link in the Documents directory of the Virtual Host I am using it with. I don’t know what the security ramifications of this might be. You, of course, will have to discern the paths for your particular setup. I keep my Virtual Hosts and Matomo at the same level.

ln -s ../matomo matomo

Browse to the newly installed system, and work through the installation. You will likely have to install some PHP extensions to get the system working fully. I had to install mbstring.

Update you apt so you get that latest

apt update

First find the package

apt-cache search mbstring

php-mbstring - MBSTRING module for PHP [default]
php-patchwork-utf8 - UTF-8 strings handling for PHP
php-symfony-polyfill-mbstring - Symfony polyfill for the Mbstring extension
php-symfony-polyfill-util - Symfony utilities for portability of PHP codes
php7.2-mbstring - MBSTRING module for PHP

What PHP Version

php -v

PHP 7.2.24-0ubuntu0.18.04.3 (cli) (built: Feb 11 2020 15:55:52) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.24-0ubuntu0.18.04.3, Copyright (c) 1999-2018, by Zend Technologies

Ok install the correct one

apt install php7.2-mbstring

Restart the web server

systemctl restart apache2

Once you have worked through all the PHP extensions fin the link for continueing over SSL:

Next, to the database setup, bring up a console to create a user for Matomo:

Modern distrubutions allow root to connect from a local terminal instance ( ssh ) without user name and password, type mysql at the console to get the mysql-client command prompt:

Create the database:

CREATE DATABASE matomo;

Add a user

CREATE USER ‘matomo’@’localhost’ identified by ‘agoodpasswordgoeshere’;

Give the user permissions on the database

GRANT ALL ON matomo.* to ‘matomo’@’localhost’;

Head back to the Matomo installation wizard and Complete step 5 through 8 for your website. I am using WordPress so I only need the tracking code to plug into the WordPress Plugin.

The office WordPress Plugin for Matomo Let’s simply add the plugin and Activate. Using the default tracking option you should be good to go!

Leave a Reply