How to install Piwik on a CentOS VPS

Status: This OS is no longer supported

This article, “How to install Piwik on a CentOS VPS,” covers a version of CentOS that reached end of life (EOL). The developing company no longer supports it. As such, we no longer maintain this guide. If you are currently operating a server running CentOS 6, we highly recommend contacting RoseHosting’s fully managed support to upgrade or migrate to a supported version of AlmaLinux.

This article covers the installation of Piwik on a CentOS VPS. Anyone can quickly and easily complete the installation.

Piwik, a free web analytics software, powers over 300,000 websites worldwide. Piwik provides detailed, real-time reports on your website’s visitors, their 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 higher, MySQL version 4.1 or higher, and the PHP ‘mysqli’ extension, which is enabled by default.

Installation Guide

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 http://piwik.org/latest.zip

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

# unzip latest.zip -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. Ensure that the ‘apache’ user owns this directory.

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

Set up 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 your actual password.

The next step is to navigate your browser to http://yourdomain.com/piwik and finish the installation using the web interface. The system will prompt you to configure the MySQL database, create a new super user, set your website’s name and URL, and more.

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 leave a reply below. Thanks.

Leave a Comment