Table of Contents

Piwik on Simple Hosting

“Piwik is an open analytics platform currently used by individuals, companies and governments all over the world. With Piwik, your data will always be yours.” - Source

Requirements

Setup Instructions

Instance configuration

If you haven't already, create an instance :

$ gandi paas create --type phpmysql --name paas_name

Attach an address as a vhost (example: piwik.domain.tld):

$ gandi vhost create --piwik.domain.tld paas_name

PHP configuration

Piwik requires a specific option to be set in your custom-php.ini file in order to install correctly.

Connect to the SSH console:

$ gandi paas console paas_name

Then edit the file /srv/data/etc/php/custom-php.ini and add the following line :

always_populate_raw_post_data=-1

Save the file, exit from the console, and then reboot the instance for the changes to take effect.

$ gandi paas reboot paas_name

Database configuration

Next we'll create a database named piwik, a database user named piwik with password CHANGE_ME, and assign privileges for the user to the database.

Connect to the SSH console :

$ gandi paas console paas_name

Login to the MySQL command-line environment and run the following commands :

$ mysql -u root -p

mysql> CREATE DATABASE piwik;
Query OK, 1 row affected (0.01 sec)

mysql> CREATE USER piwik;
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL ON piwik.* to 'piwik'@'localhost' identified by 'CHANGE_ME';
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> quit

Deploy code

On your local computer, clone the empty git repository associated with the vhost :

$ gandi paas clone --vhost piwik.domain.tld paas_name

Download the piwik installation files into the htdocs folder :

$ cd piwik.domain.tld
$ wget http://builds.piwik.org/piwik.zip
$ unzip piwik.zip
$ mv piwik htdocs

Commit the changes and deploy the code :

$ git add .
$ git commit -am 'First commit of piwik installation'
$ git push gandi master
$ gandi deploy

Install Piwik

At this point you've installed and configured Piwik for tracking website analytics. You'll need to add the Javascript code provided by Piwik into the webpages you wish to track. When those webpages are then visited by end-users, the Javascript code will send the analytics details to your Piwk installation.

For more details on configuration and optimizing Piwik, please refer to their documentation.

Additional reading