Toggle navigation

Piwik Image Guide

Version 3.0.2

Websoft9 Piwik is a pre-configured, ready to run image for running Piwik on Alibaba Cloud.

Piwik is now a leading Open Source Web Analytics Platform, used by more than 1.000.000 websites in 150 countries.Piwik prides itself on continually innovating and improving the analytics experience for users.Piwik and InnoCraft Recognised in 2016 Gartner Market Guide for Web Analytics (2016)

Software Version: Piwiki3.0.2
Software directory: /data/wwwroot/default/piwik

Basic software environment: LAMP
PHP Configuration File: /usr/local/php/etc/php.ini
Virtual host Configuration File directory: /usr/local/apache/conf/vhost
Virtual host Configuration Command: /root/oneinstack/vhost.sh

Database install directory: /usr/local/mysql
Database data directory: /data/mysql
Database Configuration File: /etc/my.cnf

After the installation of Image,please verify it

  • Login on Alibaba Cloud console,get you Internet IP Address
  • Open you Chrome or Firefox on your local PC,visit the http://Internet IP Address/
  • If verify successfully,you can enter the boot page of Websoft9 below
  • If no response from browser,please check the Security Group settings to ensure that port 80 is been allowed

This Image use MySQL for database

#default user/password:root/123456

MySQL User Guide: Click here

Step1. Create a database

1.login in MySQL:

Method 1:Use following URL to open phpMyAdmin page: http://< Public net IP >/phpMyAdmin

Method 2:Use SSH command to login in.

mysql -uroot –p                                #enter mysql console

 #default user/password:root/123456            More MySQL User Guide: Click here

 

2.create a database:

MySQL [(none)]> create database mydbname;

MySQL [(none)]> show databases;

 

3.Create a Database User and grants permissions to the User:

MySQL [(none)]> grant all privileges on mydbname.* to username@'localhost' identified by 'userpassword';

MySQL [(none)]> flush privileges;

MySQL [(none)]> exit;

before2

Step2. Add a virtual host

Use SSH Command to Add a virtual host:

[root@iZbp1i4rjdsy216yq7lgucZ ~]# cd /root/oneinstack
[root@iZbp1i4rjdsy216yq7lgucZ oneinstack]# ./vhost.sh

Step3. Install Piwik

Open your domain name via browser:
1. Select a language, Click “NEXT”;

2. Click “NEXT”;

3. Fill in database configration, Click “NEXT”;

4. Click “NEXT”;

5. Set super user accunt, Click “NEXT”;

6. Please setup the first website you would like to track and analyse with Piwik, Click “NEXT”;

7. To track your web traffic with Piwik you need to make sure some extra code is added to each of your webpages, Click “NEXT”.

8. Your Piwik installation is complete. Make sure your JavaScript code is entered on your pages, and wait for your first visitors! ,and then Click “CONTINUE TO PIWIK”:

9. Fill in your super user and password, Click “SIGN IN”;

The Piwik dashboard:

Piwik is an open platform. Being a platform has the advantage that Piwik can be extended and customised using Plugins.By default Piwik comes with 40+ plugins which are officially maintained by the core team.Then you can find all these plugins on the Marketplace.

Besides those Plugins that we bundle with the Piwik Platform, and besides those Plugins available on the Marketplace, there are also other kinds of Extensions (or sometimes called Add-ons or Modules or Plugins) that may be useful to you. These modules help you integrate Piwik into your Website. There are such modules for most of the popular tools:

Install Plugin

To get started installing a plugin, login as a Super User. In the top menu, click “Administration”. In the left menu click “Marketplace”. There are a few ways to install a plugin in Piwik:

  1. Install a new plugin using the Marketplace: on the Marketplace page you can browse existing plugins, if you want to install one of those plugins, click on “Install” button.
  2. Upload a Plugin ZIP file to Piwik: if you were given the ZIP file of a plugin, you will need to upload it to Piwik. To do so, login to Piwik as a Super User, click on Settings and then on the “Marketplace” page, click on “upload a zip file”. Note: the first time you want to upload a custom plugin you will activate this feature once by editing your config/config.ini.php file and below the category [General] add: enable_plugin_upload=1.
  3. Install a new plugin manually: this last technique only works if you have direct access to the Piwik server. Uncompress the Plugin zip file that you wish to install in Piwik. This should create a directory with the name of the plugin. Copy this uncompressed folder into your server in the directory path/to/piwik/plugins/.

By default, when you install a plugin it is not activated. To activate a plugin, go to the “Plugins” page in Administration and click “Activate” next to the plugin name.

Install Theme

The Themes Marketplace for Piwik contains several Themes that you can use. To use one of these Themes in your Piwik:

  • Login your Piwik as Super User
  • Go to Administration
  • Click on Plugins in the left menu
  • Click on Manage themes in the top of the Plugins page
  • Click on Install new themes
  • Choose your theme in the list, then click Install

Congratulations, you are now using a new Theme for your Piwik Analytics service!

If you want to go back to using the default Piwik Theme called Morpheus, in the Manage themes screen, click Deactivate on your currently enabled Theme.

To learn how to create a new Theme for Piwik, check out our guide Theming Piwik.

Backup is very import for using any CMS

Backup

To backup Piwik:

  1. Regularly backup the Mysql database containing Piwik tables (eg. using an existing Mysql backup script)
  2. Regularly backup the file piwik/config/config.ini.php
  3. Regularly backup any Plugin you may have installed from the Marketplace, stored in piwik/plugins/*folder

Restore

To restore a Piwik backup:

  1. Import the Mysql backup data in a new Mysql database you have created
  2. Download the latest version of Piwik, unzip and upload
  3. Copy the file config.ini.php from the backup into your new piwik setup. You might have to edit the database connection settings in the file if they have changed.
  4. Copy any Third party Plugin installed from the Marketplace from the backup (or download from the marketplace the latest version of these plugins) and copy them into your new piwik setup.
  5. Visit Piwik and check that everything is working correctly!

Updating Piwik is easy and we hope you will always use the latest version of Piwik! It is possible to update from any old version to the latest one.

The One-Click Piwik Update

Piwik has the Update interface for you,you can use the one-click upgrade and update your Piwik in 10 seconds – in just one click of a button.To carry out the one-click update, the Piwik folder needs to have the correct permissions on your web server, to allow Piwik to download the file, extract Piwik and overwrite the existing files.

  1. Set Write Permissions(CHMOD 0755, In some cases, the auto update might still not work, try to change the owner of the piwik to your web server user, or temporarily CHMOD 0777.) on the Piwik folder with FTP or Putty
  2. Go to the administrator dashboard you can see the new update info box when there have new version
  3. Click on the Alert Box in Piwik,you can enter the update wizard,you can update to version 3.0.4 automatically or download the package and install it manually
  4. Click the button “Udate Automatically”,and the update is complete when you receive the message  “Piwik has been successfully updated!”

 

 

The Manual Three-Step Update

If for some reason the one-click update doesn’t work for you, you can still update Piwik using FTP.

  1. Please back up your Piwik configuration file config/config.ini.php
  2. Replace the Piwik files with the latest version
    You can download the latest Piwik release from builds.piwik.org/piwik.zip. After downloading it, you can extract it to your computer.If you upload these files using FTP to your Piwik server, please make sure all files are transferred in binary mode. It is not needed to delete your old Piwik files before transferring the new ones. The new files should overwrite all the old files with the same names.
  3. Visit your Piwik installation in your web browser. If your new instance of Piwik requires changes to be made to the database, you will see this screen:

    This will update your database so that it is compatible with the latest code.Please be patient: database updates (for example adding a new index) can take a few minutes. Do not close your browser or click refresh during this process. If you fail to carry out this step correctly your Piwik installation may display incorrectly or not work at all.

Piwik has to be installed on a server with both PHP and MySQL. At the end of the 5-minute installation, Piwik will give you a Javascript tag which you add to the bottom of each page of your website. Piwik will then record the activity across your website within your database. Piwik aggregates this data to provide detailed web analytics reports about your visitors, page views, referrer information, search engine keywords, Ecommerce, campaigns and much more! As well as tracking via the Javascript file, you can also import web server access logs into Piwik, or use the Tracking API.

To track your web traffic with Piwik you need to make sure some extra code is added to each of your webpages.In most websites, blogs, CMS, etc. you can use a pre-made plugin to do the technical work for you. (See our list of plugins used to integrate Piwik.) If no plugin exists you can edit your website templates and add this code to the </head> tag which is often defined in a ‘header.php’, ‘header.tpl’ or similar template file.

Using plugin for tracking

Piwik currently can easily integrate with 100+ technologies including Content Managing Systems, Online Shops, Forums, Frameworks and more.

Please download the plugins from:https://piwik.org/integrate/

Using JS codes for tracking

Make sure this code is on every page of your website. We recommend to paste it immediately before the closing </head> tag.

<!-- Piwik -->
<script type="text/javascript">
  var _paq = _paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="//47.88.224.34/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 Piwik Code -->

you can get these codes from the dashborad of Piwik

If you have thousands of page views per day or more, check out the guide below to make sure Piwik works for you.

Websoft9  Piwik  Image have installed the phpMyadmin

phpMyAdmin install directory: /data/wwwroot/default/phpMyAdmin

Linux

Following is the step for access phpMyadmin

  1. Open Chrome or Firefox on your local PC
  2. visit the http://Internet IP Address/phpMyAdmin,you can enter the login page
  3. select you language,Username:root,Password:123456
  4. Click the button “Go”

Windows

Following is the step for access phpMyadmin

  1. User Remote Desktop Connection of Window to connect to you ECS
  2. Install a Chrome or Firefox browser on you ECS
  3. Open Chrome or Firefox on your ECS
  4. visit the http://localhost/phpMyAdmin,you can enter the login page
  5. select you language,Username:root,Password:123456
  6. Click the button “Go”

When install new extension from back-end it will not successful,may be the permissions of file and folder is not appropriate,you should change it

Web site root permissions to follow:
file 644, folder 755 ,Permissions Users and groups www
If there is a file permissions problem, execute the following three commands:

chown -R www.www /data/wwwroot/default/piwik
find /data/wwwroot/default/piwik -type d -exec chmod 755 {} \;
find /data/wwwroot/default/piwik -type f -exec chmod 644 {} \;

Modify the  /usr/local/php/etc/php.ini file to increase the allowed size for uploads:

; Maximum size of POST data that PHP will accept.
post_max_size = 16M
; Maximum allowed size for uploaded files.
upload_max_filesize = 16M

then,restart the apache

# service httpd restart

The PHP configuration file allows you to configure the modules enabled, the email settings or the size of the upload files. It is located at /usr/local/php/etc/php.ini.

There are some PHP settings that need to be sufficient to install.

e.g The values for PHP.ini below are suggested values only.

  • memory_limit – Minimum: 256M Recommended: 1G or better
  • upload_max_filesize – Minimum: 20M
  • post_max_size – Minimum: 20M
  • max_execution_time: At Least 120 Recommended: 300

After modifying the PHP configuration file, restart both Apache and PHP-FPM for the changes to take effect:

# service httpd restart

If you receive the message “Maximum execution time of 30 seconds exceeded”.You may also like to extend the max_execution_time for PHP and you can modify it by two methods below

Method one: edit your  /usr/local/php/etc/php.ini


; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 90
; Maximum amount of time each script may spend parsing request data. It's a good
; idea to limit this time on productions servers in order to eliminate unexpectedly
; long running scripts.

Method two: edit your .htaccess:


<IfModule mod_php5.c>
php_value max_execution_time 90
</IfModule>