How to Install Matomo with LAMP Stack on Ubuntu 23.10
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 23.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 23.10 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 matomo_db;
CREATE USER 'matomo_user'@'localhost' IDENTIFIED BY 'YOUR-PASSWORD-HERE';
GRANT ALL PRIVILEGES ON matomo_db.* TO 'matomo_user'@'localhost';
FLUSH PRIVILEGES;
QUIT
The above commands will give complete access to the user
matomo_user
on the databasematomo_db
. ReplaceYOUR-PASSWORD-HERE
with a safe and secure password.
Download Matomo
Download Matomo from official website : Click here.
Install the unzip
package by following command
apt install unzip
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 dev.domainhere.info.conf
for the domain with the following command:
nano /etc/apache2/sites-available/dev.domainhere.info.conf
Add the following codes:
<VirtualHost *:80>
ServerName dev.domainhere.info
ServerAlias dev.domainhere.info
ServerAdmin admin@dev.domainhere.info
DocumentRoot /var/www/matomo
ErrorLog ${APACHE_LOG_DIR}/dev.domainhere.info_error.log
CustomLog ${APACHE_LOG_DIR}/dev.domainhere.info_access.log combined
<Directory /var/www/matomo/>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Replace
dev.domainhere.info
with your actual Domain Name.
Edit the PHP config filephp.ini
,
nano /etc/php/8.2/apache2/php.ini
Add the following lines at the end of the file,
extension=mysqli.so
extension=pdo.so
extension=pdo_mysql.so
Save and exit the file.
Disable the defafult configuration and enable the new site configuration using the following command,
a2dissite 000-default.conf
a2ensite dev.domainhere.info.conf
Now Restart the Apache service and check the status,
systemctl restart apache2
systemctl status apache2
Enable and reload Firewall:
ufw allow 80/tcp
ufw allow 443/tcp
ufw reload
Install Let’s Encrypt SSL Certificate
Let's issue an SSL certificate for the domain for this we will need a snap package for Ubuntu 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
Configuring Matomo
Now open the URL from your browser, this will redirect you to configuring the final parts of the Matomo installation.
https://dev.domainhere.info
Replace the domain
dev.domainhere.info
with the actual IP or domain configured on your server.
Input the Database details which was configured earlier. Follow the below steps:
Done! Now you have successfully installed Matomo with LAMP Stack on Ubuntu 23.10.
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