Install Piwik on Ubuntu 16.04 LTS

Im Durchschnitt wird dieses Tutorial Install Piwik on Ubuntu 16.04 LTS mit 5 bewertet, wobei 1.0 die schlechteste und 5.0 die beste Bewertung ist. Es haben insgesamt 906 Besucher eine Bewertung abgegeben.

Install Piwik on Ubuntu 16.04 LTS

Ubuntu Webserver
Install Piwik on Ubuntu

Mehr Code gibt´s
hier!

Cloud - einfach besser machen?

Introducing

If you run a website or even several, it is usually also interested in how the site gets to visitors, where its visitors come from, and of course how many visitors are in the details. There are so-called monitoring tools. Google Analytics is probably the best known. Now, however, not everyone wants to store everything on Google or is sometimes by data protection regulations not even in the position to do so. In short: A powerful monitoring tool with many features, which you can host yourself, must. And that’s where Piwik comes in, because Piwik is exactly that – a powerful monitoring tool with many features. Today, I’ll show you how to install Piwik 3 on a cloud server, as an example, I take a Ubuntu 16.04 LTS Server. With gridscale, you can click on your own server with just a few clicks and in a few seconds.

Step 1: Prepare the server

I am assuming that you are already running a Websever on your Ubuntu 16.04 LTS Server because Piwik is a monitoring tool for web site administrators. If you want to create an extra server for Piwik, please create a LAMP server first. How to do this:
Install LAMP Server on Ubuntu (German only).

My recommendation is to create an extra sub-domain for Piwik. For example, this could be monitoring.my-domain.tld.

First, create a folder in /var/www/, where the Piwik files are stored:

 $ mkdir/var/www/piwik

Next you set up a Cofig, which routes your subdomain to the correct directory:

$ nano /etc/apache2/sites-available/piwik.conf

Copy the following text into the file and finally change the paths and domains:

<VirtualHost piwik.my-domain.tld:80>
        ServerName piwik.my-domain.tld

        ServerAdmin webmaster@my-domain.tld
        DocumentRoot /var/www/piwik

        <Directory /var/www/piwik/>
             Options Indexes FollowSymLinks MultiViews
             AllowOverride All
        </Directory>

        LogLevel debug
        ErrorLog ${APACHE_LOG_DIR}/piwik-error.log
        CustomLog ${APACHE_LOG_DIR}/piwik-access.log combined
</VirtualHost>

My recommendation for you: Get for your sub-domain now a free SSL certificate from Let’s Encrypt:

$ sudo apt-get -y install python-letsencrypt-apache && letsencrypt -d piwik.my-domain.de

During installation, you will be asked for your e-mail address, but this will not be published anywhere. Then you accept the Terms of Service and finally select Secure for the installation type.

Next, download the latest version of Piwik and unpack the zip-file into the root directory of your website and delete unnecessary files. Then enter the Apache user as owner:

$ cd /var/www/ && wget https://builds.piwik.org/piwik.zip && unzip piwik.zip && rm -r 'How to install Piwik.html' piwik.zip && chown -R www-data:www-data ./piwik

If your unzip tool is not already installed on your server, you can do this with the following command:

$ sudo apt-get -y install unzip

What is missing is a database for Piwik. To log into your MySQL server:

$ mysql -u root -p

And create a user and a database for Piwik:

$ create database piwik;
$ create user piwik@localhost identified by 'my_passwort';
$ grant all privileges on piwik.* to piwik@localhost;
$ flush privileges;
$ exit;

So that Piwik is still running properly still missing a few trifles:

$ sudo apt-get -y install php-mbstring php-mysqli php-pdo-mysql php-gd php-dom && sudo service apache2 restart

Step 2: Set up Piwik

Now it’s finally time and you can call your Piwik sub-domain in your browser:

https://piwik.my-domain.tld

First, your server is checked, if everything is installed. If you have followed the instructions, nothing should be missing. So you can click Next. On the next page you will be asked for the access data for your database. Enter here the data of the user “piwik”, which you created, not the root access data. And then go back to Next. If everything is correct, you will be asked to click again on Next, of course you are following the request.

Then enter the access data for your main use and click Next again.

You will then enter the name and address of one of your web pages you wish to monitor. Important, if you have a shop: place the corresponding in Piwik. Once you have entered everything, click Next.

On the last page you will be provided with a tracking code that looks something like this:

<!-- Piwik -->
<script type="text/javascript">
  var _paq = _paq || [];
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
	var u="//piwik.meine-domain.tld/";
	_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><noscript>

<img src="//piwik.meine-domain.tld/piwik.php?idsite=1" style="border:0;" alt="" />

</noscript><!-- End Piwik Code -->

Copy this to the & lt; head & gt; section of your web page. Important: The code has to be stored on every page, so also on every side of the page. If you are using a CMS, ask if there is a configuration option for the header. Most CMS systems offer this setting.

Once you have inserted the code, visit the page and go back to Piwik. After clicking again on Next and then logging in with your admin account, you should already see that you had a visitor.

Your Piwik is now ready for use!

Zurück zur Tutorial Übersicht Back to Tutorial Overview

Mehr Code gibt´s
hier!

Cloud - einfach besser machen?

Introducing If you run a website or even several, it is usually also interested in how the site gets to visitors, where its visitors come from, and of course how many visitors are in the details. There are so-called monitoring tools. Google Analytics is probably the best known. Now, however, not everyone wants to store […]

Schade, dass dir der Artikel nicht gefallen hat.
Was sollten wir deiner Meinung nach besser machen?

Thank you for your feedback!
We will get back to you as soon as the article is finished.

Übrigens: kennst du schon unser Tutorial zum Thema PostgreSQL 10 Master-Slave Replication?