Install Piwik on Ubuntu 14.04

Piwik is an open source analytics software system that can be installed on a server to view the traffic of its websites in real time. It is an excellent alternative to web-based Analytic solutions like Google Analytics. This guide will teach us how to install and set up Piwik on your Ubuntu 14.04-based AKLWEB HOST Server.

Requirements

Before we can move ahead, make sure that your server has all the required updates. Run the following commands on the terminal for that.

sudo apt-get update
sudo apt-get upgrade

Your server needs to have the LAMP (Linux, Apache, MySQL, and PHP) stack installed for Piwik to run. Furthermore, you will need an additional PHP library for Piwik to work. Run the following command to install it.

sudo apt-get install php-gd

That marks the completion of all the steps required for Piwik to work.

Download Piwik

Make sure you are in the user directory first.

cd /var/www/piwik

Grab the latest Piwik release.

wget http://builds.piwik.org/latest.zip

Unzip and move the Piwik release to the user directory.

unzip latest.zip

Set up the proper file permissions to the tmp and config directories.

chmod a+w /var/www/piwik/tmp
chmod a+w /var/www/piwik/config

Set up proper user permissions on the complete piwik directory.

chown -R www-data:wwww-data /var/www/piwik

Setup Stats Domain

To access your Piwik page, you can either install it using your server’s IP address or you can set up a custom domain name. You can skip this process if you are comfortable accessing Piwik via the IP address. If you would like a usable URL for the stats page, then continue reading.

Let’s assume that your domain is domain.com and that you want to access Piwik at stats.domain.com. For that, you would need to set up the “A record” first for stats.domain.com with your DNS provider. If you don’t know how to do that, then contact the support team from where you registered your domain.

After setting up the “A record”, we need to bind the stats domain to the server via the virtual host feature of Apache. We will need to set up a custom vhost entry for the stats domain. Run the following commands on the terminal.

sudo nano /etc/apache2/sites-available/stats.domain.com.conf

Add the following lines to the above file.

<VirtualHost *:80>
   ServerAdmin admin@stats.domain.com
   ServerName stats.domain.com
   ServerAlias stats.domain.com
   DocumentRoot /var/www/piwik/
   ErrorLog /var/www/piwik/logs/error.log
   CustomLog /var/www/piwik/logs/access.log combined
</VirtualHost>

Replace the above email address with a working email address of yours. We would also need to create the log directory.

mkdir /var/www/piwik/logs

Now that the virtual host is setup, we need to activate it with the following commands.

sudo a2ensite stats.domain.com.conf

Restart the Apache server for the configuration to take effect.

sudo service apache2 restart

Install Piwik

Now that we have set up Piwik, you can access it either via http://<yourserverIP>/piwik or http://stats.domain.com URL from your web browser. Follow the on-screen instructions to complete the installation. Make sure to enter the proper database user that has the permissions to create a table during the installation.

We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies

More