How to Install Matomo with LAMP Stack on Ubuntu 20.04
Matomo, formerly Piwik, is a free and open-source web analytics application developed by a team of international developers, that runs on a PHP/MySQL webserver. It tracks online visits to one or more websites and displays reports on these visits for analysis. In this article, we are going to learn how to install Matomo on Ubuntu 20.04. So, let’s get started.
Checkout the Matomo Project Here.
Try this wiki on our VPS. Starting at just $5/month with 24x7 In-house customer support.
Pre-requisites :
-
A system with Ubuntu 20.04 installed and running.
-
root
access to the system. - LAMP Stack installed and running, for this, you can refer to one of our guides on installing the LAMP Stack (Apache, MariaDB, and PHP).
Once you're all set, we'll proceed with Matomo installation and configuration.
Create Database
Let us begin with creating a Database and a user. We will then grant the required privileges to the user so it can interact with the Database.
mysql -u root
CREATE DATABASE crowncloud;
CREATE USER 'crowncloud'@'localhost' IDENTIFIED BY 'YOUR-PASSWORD-HERE';
GRANT ALL PRIVILEGES ON crowncloud.* TO 'crowncloud'@'localhost';
FLUSH PRIVILEGES;
QUIT
The above commands will give complete access to the user
crowncloud
. ReplaceYOUR-PASSWORD-HERE
with a safe and secure password.
Install Let’s Encrypt SSL Certificate
Let's issue an SSL certificate for the domain for this we will need a snap package for Debian operating system.
We will update and install the snap package on the system:
apt update
apt install -y snapd
snap install core && sudo snap refresh core
Next, with the help of snap, we will install the certbot client which is used to create Let's Encrypt certificates:
snap install --classic certbot
ln -s /snap/bin/certbot /usr/bin/certbot
Install SSL Certificate
Use the certbot command to issue a Let's Encrypt certificate. The command will auto-detect the domains available or configured in the vHost configuration:
certbot --apache
Download Matomo
Download Matomo from official website : Click here.
cd /var/www/
wget https://builds.matomo.org/matomo.zip && unzip matomo.zip
rm matomo.zip
cd matomo
mkdir tmp
Setting up File Permissions
Let's make the folders readable.
chown -R www-data:www-data /var/www/matomo
chmod -R 755 /var/www/matomo
Configuring Apache vHost
Create a new apache configuration file dev8.domainhere.info.conf
for the domain with the following command:
vi /etc/apache2/sites-available/dev8.domainhere.info.conf
Add the following codes:
<VirtualHost *:80>
ServerName dev8.domainhere.info
ServerAlias dev8.domainhere.info
ServerAdmin admin@dev8.domainhere.info
DocumentRoot /var/www/matomo
ErrorLog ${APACHE_LOG_DIR}/dev8.domainhere.info_error.log
CustomLog ${APACHE_LOG_DIR}/dev8.domainhere.info_access.log combined
<Directory /var/www/matomo/>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Change
dev8.domainhere.info
withYour Domain Name
.
Now, press the Esc
key, and type :wq!
and press the Enter
key to save and exit the file.
Now, restart & check the apache with the following commands:
systemctl restart apache2
systemctl status apache2
Enable Firewall:
ufw allow 80/tcp
ufw allow 443/tcp
Configuring Matomo
Now open the URL from your browser, this will redirect you to configuring the final parts of the Matomo installation.
https://dev8.domainhere.info
Replace the
dev8.domainhere.info
with the actual IP or domain configured on the server.
Input the Database details which was configured earlier. Follow the below steps:
Now you have successfully installed Matomo with LAMP Stack on Ubuntu 20.04.
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS