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.
Make sure you are in the user directory first.
Grab the latest Piwik release.
Unzip and move the Piwik release to the user directory.
Setup the proper file permissions to the
chmod a+w /var/www/piwik/tmp chmod a+w /var/www/piwik/config
Setup proper user permissions on the complete
chown -R www-data:wwww-data /var/www/piwik
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
domain.com and that you want to access Piwik at
stats.domain.com. For that, you would need to setup 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 setup 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 firstname.lastname@example.org 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.
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
Now that we have setup Piwik, you can access it either via
http://stats.domain.com 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.