Piwik

Prerequisite

 * Nginx
 * Let’s Encrypt
 * PHP
 * MariaDB

Add Repository
Piwik is not present in Debian repositories. However they provide their own repository. You can add it using

Configure PHP
Edit file   and add   to the   setting.

Reload PHP:

DNS
Create a DNS entry for piwik. For this guide, we will use.

Create Database
For the rest of the guide, we will use a dedicated database and user named.

You can create them using PhpMyAdmin or any other method.

Initial Setup
Open your browser to your piwik website ( https://piwik.example.org ) and follow the instructions.

You will need to enter the credentials for the database user that we just created. You will also create the first user of your website.

Once this is done and you can log into your website properly, time to remove the temporary password from nginx.

Edit file  and remove the two lines that start with.

Reload Nginx with

Cron
By default, Piwik will preprocess data when you see it in the browser. This can give a slow UI depending on the data that you have. To process can be replaced by a cron job for better performance.

To set the cron job, edit file  to uncomment the line and replace the URL Once the cron is set, you can disable the reports in the UI. Open administration pages, go to section Settings / General and disable archiving in the UI



Preparation
A few days before the actual migration change the TTL of your DNS entry to something short like 1 minute. This will ensure that when you switch your DNS record to the new server, users start using your new server as fast as possible.

Installation
On the new server, follow the normal installation steps. You will just need the following modifications:
 * Do not point the DNS record to your new server yet.
 * From the Nginx config, remove the two lines that start with
 * You cannot get your ssl certificate yet. Do not run certmanage and do not uncomment ssl related lines.

Configuration
Transfer file  to your new server.

Edit the database section and change the database password.

Copy Database
Run this step and the next one as fast as possible.

On the old server, backup you database using Copy the file  to the new server.

And restore it on the new server using

Switch server

 * Switch the DNS entry to the new server
 * Run the command


 * Uncomment the ssl related lines in  and run