Install Piwik on Ubuntu 14.04

Last Updated: Thu, Nov 27, 2014
Linux Guides Ubuntu
Archived content

This article is outdated and may not work correctly for current operating systems or software.

Piwik is an open source analytics software system which can be installed on a server to view traffic of its websites in real time. It is an excellent alternative to web-based Analytic solutions like Google Analytics. In this guide, we will learn how to install and setup Piwik on your Ubuntu 14.04 based VULTR Server.


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 in order for Piwik to run. If you haven't done it yet, then you can follow our guide to install and setup the stack. 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.


Unzip and move the Piwik release to the user directory.


Setup the proper file permissions to the tmp and config directories.

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

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

Setup 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 setup 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 and that you want to access Piwik at For that, you would need to setup the "A record" first for 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 setup a custom vhost entry for the stats domain. Run the following commands on the terminal.

sudo nano /etc/apache2/sites-available/

Add the following lines to the above file.

<VirtualHost *:80>




    DocumentRoot /var/www/piwik/

    ErrorLog /var/www/piwik/logs/error.log

    CustomLog /var/www/piwik/logs/access.log combined


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

Restart the Apache server for the configuration to take effect.

sudo service apache2 restart

Install Piwik

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

Want to contribute?

You could earn up to $600 by adding new articles.