How to install piwik analytics tools on Ubuntu 16.04

In this tutorial I will show you how to install piwik on Ubuntu 16.04 .   install piwik on ubuntu

Piwik is the leading Free/Libre open analytics platform.

Piwik is a full featured PHP MySQL software program that you download and install on your own webserver. At the end of the five minute installation process you will be given a JavaScript code. Simply copy and paste this tag on websites you wish to track and access your analytics reports in real time.

Piwik aims to be a Free software alternative to Google Analytics, and is already used on more than 1,000,000 websites. Privacy is built-in!

Prequisites for piwik

There are some requirements that we need before installing piwik analytics tool. Let’s see what we need.

From Piwik website:

  • Webserver such as Apache, Nginx, etc.
  • PHP version 5.5.9 or greater
  • MySQL version 5.5 or greater, or MariaDB
  • (enabled by default) PHP extension pdo and pdo_mysql, or the mysqli extension.

Install Apache, php and mysql

In this step we will install install apache, php and mysql-server if it is not installed before.

sudo apt-get install wget php7.0 php7.0-curl php7.0-gd php7.0-cli mysql-server php7.0-mysql php-xml php7.0-mbstring libapache2-mod-php

You need to provide MySQL root user password while installation.

Read Also: How to install piwik analytics tool on centos 7?

Setting up database

Start the services of database

systemctl start mysql
systemctl enable mysql

Read Also: Useful s3 commands

Create database for piwik

Execute the following commands to create a database with user piwik and password. You should change password with some super secure password as I used this password for tutorial purpose only.

mysql -u root -p
mysql> CREATE DATABASE piwik;
Query OK, 1 row affected (0.00 sec)

mysql> CREATE USER 'piwik'@'localhost' IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)

mysql> LOCK TABLES ON piwik.* TO 'piwik'@'localhost';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> quit

Installing piwik

Firstly we will download the zip of piwik from their website. You can also download zip from here:

cd /var/www/html

Change the conf  for php

By default apache2 look for index.html so we need to change the priority of index.php. Open the conf dir and make changes as below:

vim /etc/apache2/mods-enabled/dir.conf

I will look like this:

<IfModule mod_dir.c>
DirectoryIndex index.html index.cgi index.php index.xhtml index.htm

We need to change the position of index.php on the first place as shown below:
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.xhtml index.htm

Starting Apache

systemctl start apache2
systemctl enable apache2

Web Console

You can go to the following link to get the web console


Now you can configure piwik.

This is how you can install piwik analytics tool on Ubuntu.

Read Also: How to install bucardo for postgres replication

If you got some issues installing this tutorial please feel to comment below.

Leave a Reply

Your email address will not be published.


The reCAPTCHA verification period has expired. Please reload the page.

48-Hour Flash Sale! Courses from just $10.99