Your cloud servers see tons of visitors and usage. So much so, you might want to keep tabs on the analytics of those servers. One way to do so is using the Matomo (formerly Piwik) Web Analytics tool. With the help of this tool, you can keep tabs on visits to your cloud servers (or any other server you might have).

I’m going to walk you through the process of installing Matomo on Ubuntu 18.04.

SEE: Vendor comparison: Microsoft Azure, Amazon AWS, and Google Cloud (Tech Pro Research)

What you need

The only things you need for this is a running instance of Ubuntu Server 18.04 and a user account with sudo privileges. I’ll do this with the idea of serving this only to an internal network. If you plan on reaching your Matomo instance from the outside world, you’ll also need a Fully Qualified Domain Name (so that you can use an SSL certificate). But since this will focus only on internal usage, we’ll skip that process here.

And with that said, let’s install.


The first thing to take care of is the necessary dependencies. Open a terminal window and issue the following command:

sudo apt install curl wget git unzip socat -y

Next install PHP and the necessary modules with the command:

sudo apt install php7.2 php7.2-cli php7.2-fpm php7.2-common php7.2-curl php7.2-gd php7.2-xml php7.2-mbstring php7.2-mysql -y

Finally install the MySQL server with the command:

sudo apt install mysql-server -y


Secure the MySQL installation with the command:

sudo mysq_secure_installation

Make sure to give the MySQL admin user a strong/unique password and answer Y to the remaining questions. Access the MySQL prompt with the command:

udo mysql -u root -p

Create the database (and the necessary user) with the following commands:


where PASSWORD is a strong/unique password.


We’ll serve up Matomo with the NGINX web server. To install NGINX, open a terminal window and issue the following command:

sudo apt-get install nginx -y

Create a new configuration file with the command:

sudo nano /etc/nginx/conf.d/matomo.conf

In that file, copy the following contents:

server {

listen 80;

server_name SERVER_NAME;

root /srv/matomo;
index index.php index.html;

access_log /var/log/nginx/matomo_access.log;
error_log /var/log/nginx/matomo_error.log;

client_max_body_size 100M;

location / {
try_files $uri /index.php?$query_string;

location ~.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


where SERVER_NAME is either the name of the server or the IP address. Save and close that file.

Download Matamo

Next, we need to download the necessary file for installing Matamo. From the terminal window, issue the command:


Unzip the downloaded file with the command:


Move the newly created directory with the command:

sudo mv piwik /srv/matomo

Give the newly moved folder the proper permission with the command:

sudo chown -R www-data:www-data /srv/matomo/

Restart and enable NGINX with the commands:

sudo systemctl restart nginx
sudo systemctl enable nginx

Finish installation

To finish installation, point a web browser to http://SERVER_IP and walk through the user-friendly web-based installer (Figure A).

You will be required to add a tracking code to every page on your site, or install a pre-made plugin that covers a number of site types (such as Drupal, WordPress, Joomla, Sharepoint, Type3, Moodle, and many more). You will be given the Javascript tracking code for your site during installation. Copy that code into a file (you’ll need it when you go to set up your sites). If you don’t copy it, you can retrieve it from the Matomo admin page.

Once you’ve completed that process, Matomo is ready to start monitoring your site.

And that is all there is to installing Matomo on Ubuntu Server 18.04. The time you spend with the installation will pale in comparison to what it requires to add your various web sites to the monitoring. The time spent will be well worth having all of that analytical data to comb through.