How to install Piwik on a CentOS VPS

This article covers the installation of Piwik on a CentOS VPS. The installation is quite easy and fast, and can be done by anyone.

Piwik is a free web analytics software used by more than 300,000 websites worldwide. Piwik provides detailed real time reports on your website’s visitors, your visitors’ geo location, your marketing campaigns, and much more…

Minimum requirements to run Piwik on your CentOS linux vps are PHP version 5.1.3 or greater, MySQL version 4.1 or greater and the PHP ‘mysqli’ which is enabled by default.

You can check your PHP version by executing:

# php -v

You can check your MySQL version by executing:

# mysql -V

If your server meets the minimum requirements you can start with the installation.

Download the latest Piwik release from their official website:

# wget

Unzip the downloaded zip file to the Apache’s document root directory:

# unzip -d /var/www/html

If you are not sure about the location of the Apache’s document root directory, you can execute:

# grep -i '^documentroot' /etc/httpd/conf/httpd.conf
DocumentRoot "/var/www/html"

In our case it is the ‘/var/www/html’ directory.

This will create a new ‘piwik’ directory. This directory should be owned by ‘apache’:

# chown -R apache:apache /var/www/html/piwik

Setup a new MySQL user and create a new MySQL database using the following commands:

# echo "CREATE DATABASE piwikdb;" | mysql -u root -p
# echo "CREATE USER 'piwikuser'@'localhost' IDENTIFIED BY 'PASSWORD';" | mysql -u root -p
# echo "GRANT ALL PRIVILEGES ON piwikdb.* TO 'piwikuser'@'localhost';" | mysql -u root -p
# echo "FLUSH PRIVILEGES;" | mysql -u root -p

Do not forget to change ‘PASSWORD’ with you actual password.

The next step is to navigate your browser to and finish the installation using the web interface. You will be prompted to setup the MySQL database, create a new super user, setup your website’s name and URL, etc…

For more updates, you may refer to our guide on How to Install Matomo on CentOS 7.

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.

3 thoughts on “How to install Piwik on a CentOS VPS”

Leave a Comment

To prove you are human please solve the following *