Piwik

From Gentoo Wiki
Jump to:navigation Jump to:search

This article describes the installation and configuration of Piwik Web Analytics software.

Installation

USE flags

Piwik uses the gd, mysqli, pdo, and truetype USE flags on dev-lang/php. Be sure they are enabled by editing /etc/portage/package.use:

FILE /etc/portage/package.use/php
dev-lang/php fpm -exif mysqli pdo gd truetype
# required by dev-lang/php-5.6.10::gentoo
# required by dev-lang/php (argument)
>=app-eselect/eselect-php-0.7.1-r4 fpm

Emerge

root #emerge --ask --verbose dev-lang/php

In order to see geographical IP addresses, the geoip PHP extention is required:

root #emerge --ask dev-php/pecl-geoip

Configuration

php.ini

Piwik requires the following change in php.ini:

FILE /etc/php/fpm-php5.6/php.iniFPM PHP 5.6 configuration file
always_populate_raw_post_data = -1

Services

OpenRC

Restart the web server and php services. In the example below the Nginx server is used:

root #/etc/init.d/php-fpm restart
root #/etc/init.d/nginx restart

Piwik software

Change to web server public directory:

root #cd /var/www/localhost/htdocs

Download and extract piwik analytics:

root #unzip piwik.zip

Database

MySQL

Create a database and user for Piwik (using mysql example):

user $mysql -u root -p
mysql> CREATE DATABASE piwik;
mysql> USE piwik;
mysql> grant all privileges on piwik.* to user@localhost identified by 'password';
mysql> grant all privileges on piwik.* to user@'%' identified by 'password';

Create directories and change write permissions required by Piwik:

root #mkdir /var/www/localhost/piwikconfig
root #chmod a+w /var/www/localhost/htdocs/piwikconfig
root #chmod a+w /var/www/localhost/htdocs/piwik/tmp
root #chmod a+w /var/www/localhost/htdocs/piwik/config

In a browser navigate to piwik and follow the configuration instructions.

http://localhost/piwik

Change back the write permission on directories except on /var/www/localhost/htdocs/piwik/tmp:

root #chmod a-w /var/www/localhost/htdocs/piwikconfig
root #chmod a-w /var/www/localhost/htdocs/piwik/config

See also

  • Apache - The most popular HTTP server used the Internet.
  • Nginx - A robust, small, high performance web server and reverse proxy server.
  • Lighttpd - A fast, lightweight web server.