Overviews: It is an free and Open Source web analytics application. It tracks online visits to one or more websites and displays reports on these visits for analysis.
System Requirement: To run Matomo (Piwik) your host needs a couple of things:
- Webserver such as Apache, Nginx, IIS, etc.
- PHP version 5.5.9 or greater
- MySQL version 5.5 or greater, or MariaDB
- (enabled by default) PHP extension pdo and pdo_mysql, or the mysqli extension.
Installation Steps:
Install Web Site Access Analyzer “Piwik”. Piwik is different from AWStats and others, it analyzes a Web site, so it needs to add Java Script codes on a web site you’d like to analyze accesses.
Web Server Installation: Here we can use web server tool (apache2).
#apt-get install –y apache2
#service apache2 start
Database Server Installation: Here we can use database server tool (mariadb-server).
#apt-get install –y mariadb-server
#service mysql start
Php Installation: Here we can use php (version 5).
#apt-get install php5.0 php5.0-curl php5.0-gd php5.0-cli php5.0-mysql php5.0-xml php5.0-mbstring libapache2-mod-php
#service apache2 restart
#service mysql restart
Piwik data creation:
When installing Matomo (Piwik), you will need to specify a MySQL username and password. The MySQL user must have permission to create and alter tables in the database.
#mysql –u root –ppassword
- Here we create the ‘db_name’ database.
mysql>CREATE DATABASE db_name;
- After database creation we provide the permission for database user. The database user ‘db_user’ and password ‘db_passwd’ for the hostname ‘localhost’.
mysql>GRANT ALL PRIVILEGES ON db_name.* TO ‘db_user’@’localhost’ IDENTIFIED BY ‘db_passwd’;
- Update the database permission and modification for permanent.
mysql>FLUSH PRIVILEGES;
mysql>EXIT;
Piwik Source Management:
- Download the source file of piwik software
#wget http://piwik.org/latest.zip -P /var/www/html
- Extract the piwik source file at ‘/var/www/html’ location.
#unzip /var/www/html/latest.zip –d /var/www/html/
- Change the ‘ownership’ and group name of ‘tmp’ and ‘config’ directory file of piwik as ‘www-data’.
#chown –R www-data. /var/www/html/piwik/tmp /var/www/html/piwik/config
Access it from “http://Server_IP/piwik”.
Copy the code on your main index.html file.
vi /var/www/html/index.html
<!DOCTYPE html> <body><!– Matomo –>
<script type=”text/javascript”>
var _paq = _paq || [];
_paq.push([‘trackPageView’]);
_paq.push([‘enableLinkTracking’]);
(function() {
var u=”//logstash-husi23334149713.codeanyapp.com/piwik/”;
_paq.push([‘setTrackerUrl’, u+’piwik.php’]);
_paq.push([‘setSiteId’, ‘1’]);
var d=document, g=d.createElement(‘script’), s=d.getElementsByTagName(‘script’)[0];
g.type=’text/javascript’; g.async=true; g.defer=true; g.src=u+’piwik.js’; s.parentNode.insertBefore(g,s);
})();
</script>
<!– End Matomo Code –><h1>Hellow Logstash</h1></body>
</html>