Today we are going to show you how to install Piwik on an Ubuntu Cloud VPS. Piwik is a web analytics platform and it is an open source alternative to Google Analytics. It’s used by thousands of websites and it’s still open source and actively developed.
The first thing you need to do is to update your system software to the latest version available. You should always keep your system updated for security reasons. In Ubuntu, you can do this using the following commands:
apt-get update apt-get upgrade
Install PHP 7 and the required PHP extensions:
apt-get install php7.0-common php7.0-mysql php7.0-xml php7.0-cli php7.0-gd php7.0-mbstring
Restart the Apache web server for the changes to take effect:
service apache2 restart
Then, you can navigate to your ‘/var/www/html/’ directory, create a new ‘piwik’ directory, download the latest version of Piwik and unzip it into that directory. After you unzip it, navigate to the new piwik directory.
cd /var/www/html/ mkdir piwik
wget http://builds.piwik.org/piwik.zip && unzip piwik.zip
cd piwik/
Then, you will need to change the owner and the group of that directory and change the permissions of the tmp/ directory:
chown -R www-data:www-data /var/www/html/piwik chmod -R 0755 /var/www/html/piwik/tmp
Once you execute these commands, it is time to create a database and a user for your Piwik installation. You can use the following commands for that purpose:
mysql -uroot -p mysql> CREATE DATABASE piwikdb; mysql> CREATE USER piwikuser@localhost IDENTIFIED BY 'PasSwoRd'; mysql> GRANT ALL PRIVILEGES ON piwikdb.* TO piwikuser@localhost; mysql> FLUSH PRIVILEGES; mysql> quit
And with that, you are done with the server configuration.
The installation of Piwik on an Ubuntu Cloud VPS is really simple so once you finish with all these steps, you are ready to proceed with the web interface installation. Open your favorite web browser and navigate to ‘http://YOUR-IP-ADDRESS/piwik’. Do not forget to change the ‘YOUR-IP-ADDRESS’ with the real IP address of your Ubuntu VPS. Here, you will need to proceed through the system check, database setup, super user setup, website setup etc.
When you are done with the setup, add the JavaScript Tracking Code on every page of your website before the closing </head> tag.
A good way to start using this amazing tool is to visit the official Piwik website and read the official documentation: https://piwik.org/docs/
Since millions of websites today are powered by WordPress, there is a very useful Piwik plugin which will help you to add all the website stats at your dashboard. You can get the plugin at https://wordpress.org/plugins/wp-piwik/. There are much more ways to integrate Piwik with popular applications other than WordPress.
Of course, you don’t have to do any of this if you use one of our Linux Cloud VPS hosting services, in which case you can simply ask our expert Linux admins to install Piwik for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.