Piwik

Piwik is an open source software doing statistics on your website visitors. This is similar to Google Analytics except it's open source and you can host it yourself.

Installation on debian

No package is provided for debian but the installation is quite easy.

  • First of all, Apache, php and MySQL should be installed:

    $ sudo apt-get install apache2 mysql-server php5 php5-mysql
    
  • By default piwik does geolocation through visitor language which is highly unreliable, but piwik can also use a GeoIP database through different method. The easiest one being through Apache:

    $ sudo apt-get install libapache2-mod-geoip
    
  • Then a dedicated database and user should be created in MySQL:

    $ mysql -uroot -p
    
    mysql> CREATE DATABASE piwik;
    mysql> CREATE USER 'piwik'@'localhost' IDENTIFIED BY 'enter-a-password-here';
    mysql> GRANT ALL PRIVILEGES ON piwik.* TO 'piwik'@'localhost' WITH GRANT OPTION;
    mysql> GRANT FILE ON *.* TO 'piwik'@'localhost';
    mysql> FLUSH PRIVILEGES;
    
  • Download and put piwik in /srv:

    $ wget http://builds.piwik.org/latest.zip
    $ unzip latest.zip
    $ sudo mv piwik /srv/
    $ sudo chown -R www-data:www-data /srv/piwik
    
  • Create an entry in your DNS (piwik.example.net for instance).

  • Create a virtual host in Apache /etc/apache2/sites-available/piwik.conf:

    <VirtualHost *:80>
      ServerName piwik.example.net
    
      DocumentRoot /srv/piwik
      <Directory /srv/piwik/>
        Options -Indexes
        AllowOverride None
        Require all granted
      </Directory>
    </VirtualHost>
    
  • Enable it:

    $ sudo a2ensite piwik.conf
    $ sudo service apache2 reload
    
  • Open your web browser and go to http://piwik.example.net. There piwik will guide you through the end of the configuration.

  • Put piwik tracking code on all your website's pages and you are done.

References:

Comments Add one by sending me an email.