/piwik-cookbook

Installs and configures piwik analytics

Primary LanguageRubyOtherNOASSERTION

Build Status Chef cookbook

DESCRIPTION

Installs piwik using nginx and php-fastcgi either on a single server or on a cluster of servers for high traffic sites.

REQUIREMENTS

Cookbooks

  • mysql-client (to enable piwik to connect to it's MySQL server)
  • runit (for managing nginx and php-fastcgi)
  • nginx (the web server)
  • iptables (for locking down the piwik machine)
  • logrotate (for rotating nginx log files)

Platform

Tested on:

  • Debian 7

  • Ubuntu 14.04

May work where build-essential works, but other platforms are untested.

ATTRIBUTES

  • node['piwik']['version'] - The piwik version to install or upgrade to, default is 1.5.1

  • node['piwik']['install_path'] - The path where the web server will expect the piwik dir to live, default is /var/www

  • node['piwik']['php_fcgi_memory_limit'] - The memory limit for PHP, default is 128M

  • node['piwik']['php_fcgi_children'] - The number of concurrent PHP processes, default is 5

  • node['piwik']['php_fcgi_max_requests'] - Kill each PHP process after it served the given amount of requests to avoid memory bloat, default is 1000

  • node['piwik']['php_fcgi_bind_path'] - The URL or socket to let nginx talk to PHP (for fastcgi's config), default is /tmp/.php-fcgi-socket

  • node['piwik']['php_fcgi_pass'] - The URL or socket to let nginx talk to PHP (for nginx's config), default is unix:/tmp/.php-fcgi-socket

The following attributes are only used by the piwik::slave recipe to connect it to an existing piwik installation

  • node['piwik']['config']['superuser']['login'] - The username of the piwik superuser, default is `override_attribute in role!´
  • node['piwik']['config']['superuser']['password']config - superuser - password - The MD5 hash of the password of the piwik superuser, default is override_attribute in role!
  • node['piwik']['config']['superuser']['email'] - The email address of the piwik superuser, default is override_attribute in role!
  • node['piwik']['config']['superuser']['salt'] - The salt generated by piwik on installation, default is override_attribute in role!
  • node['piwik']['config']['database']['host'] - The database server, where the piwik DB lives, default is localhost
  • node['piwik']['config']['database']['port'] - The port of the database, default is 3306
  • node['piwik']['config']['database']['username'] - The username to connect to the database, default is piwik
  • node['piwik']['config']['database']['password'] - The database password, default is override_attribute in role!
  • node['piwik']['config']['database']['dbname'] - The name of the database with the existing piwik installation, default is piwik
  • node['piwik']['config']['database']['adapter'] - The PHP database adapter to be used, default is PDO_MYSQL
  • node['piwik']['config']['database']['tables_prefix'] - The prefix of the existing piwik tables, default is piwik_
  • node['piwik']['config']['database']['charset'] - The charset of the existing piwik tables, default is utf8

USAGE

For low traffic sites

Just add recipe[piwik] to your node's run list. This will download and install piwik on the host. It will ask you for superuser and database connection params when you first hit /index.php on your new piwik server.

For high traffic sites

If you run a medium to high traffic site (> 100.000 visits/day) you should use the piwik::master and piwik::slave recipes. The piwik::master will install piwik on the host using the default recipe. You'll need to do the manual piwik configuration hitting /index.php as described above.

Additionally the piwik::master recipe will install an hourly cron job to run the piwik archive.sh script to pre-calculate reports. You should disable report generation on hitting the frontend in the piwik settings.

If you want to setup a cluster of piwik tracking servers, all connected to the very same piwik DB, you can setup additional tracking servers using the piwik::slave recipe. To be able to use it, go to your (manually configured) master and take all required values from piwik/config/config.ini.php and overwrite the attributes of the piwik cookbook with those values. Then a new server using the piwik::slave recipe will automatically connect to the existing piwik installation. You can now use a load balancer to distribute tracking requests to all of your piwik servers.

LICENSE and AUTHOR

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.