Fully Open Edge Cloud

How To Download Matomo software By Stack Lamp In Buildout

How To Download Matomo software In Rapid.Space Theia Runner
  • Last Update:2023-01-31
  • Version:001
  • Language:en

Agenda

  1. Prerequisites
  2. Create software profile
  3. Download matomo
  4. Verification 

This tutorial will teach you how to download matomo source files to your instance via LAMP stack.

Prerequisites

Video of tutorial

Create a new file named "software.cfg"

Create a new folder named matomo-tutorial in "/project/slapos/software/" ( right-click on folder software, select New Folder ) to put all files about deployment.

Then create a new file software.cfg in it ( right-click on folder matomo-tutorial, select New File ). Every software in slapos starts with a software configuration file. Slapos will first start to download and compile necessary components and stacks according to the content of file software.cfg

Edit the file "software.cfg" ( buildout )

Add section buildout, include some required components and stacks, The specific environment where matomo runs can be found on matomo github. We need Php, Mysql, and a web server like Apache,  that means all we need is a LAMP, which means Linux, Apache, Mysql, Php.

Fortunately, among the existing stacks, we have already LAMP. It has already made the configuration of Mariadb and Apache-php for us so we can directly use it to download and configure Matomo, instead of writing Apache-php and Mariadb buildout from scratch. So in the section buildout, add a new keyword extends to include the stack Lamp so that we can use it. And then we need to add slapos stack, which includes some basic things in slapos, it is needed for 99% of software in slapos.

Then in the keyword parts, add two lines, one is slapos-cookbook and another is the instance. Slapos-cookbook is a library that includes some useful function that can help us deploy matomo more easily and for those functions, If you're not sure what this is, don't worry, we'll explain it in more detail when we use it later. The purpose of instance is to make sure all instances of matomo will be created. 

[buildout]
extends =
# LAMP stands for Linux, Apache, MySQL, PHP
  ../../stack/lamp/buildout.cfg
# "slapos" stack describes basic things needed for 99.9% of SlapOS Software
  ../../stack/slapos.cfg

parts =
# Call installation of slapos.cookbook egg defined in stack/slapos.cfg (needed
# in 99,9% of Slapos Software Releases)
  slapos-cookbook
# to create file instance.cfg of all instances
  instance

Edit file "software.cfg" (application)

Add a new section "application", set the keyword url to the URL link of matomo source zip file.
# download matomo
# The specific process of downloading and decompressing is defined in stack lamp
[application]
url = https://builds.matomo.org/matomo-4.7.1.zip
md5sum = 8d592676bc2c0d51363ad7b2caf171fe
archive-root = matomo

The URL will be passed to the stack LAMP, and after receiving it, LAMP will download and decompress it , finally moving it to the root resource directory of the apache server .
The md5sum is the check code of the file download to verify its integrity , when the md5 code of the file we download from the internet does not comply with it, slapos will give us an error.

Edit file "software.cfg" (custom-application-deplyment)

Add a new section "custom-application-deployment", set the some information about database.
[custom-application-deployment]
db-name = matomo
db-user = matomo
db-password = 12345678

Use a Script to supply and request an instance

For confirming everything in this step is fine, we should check if the Matomo source file has been downloaded. So we need to build software and request an instance for it.

So create a new bash script named request-matomo-instance.sh in  "~/srv/project" ( right-click on folder project, select New File ) to request an instance of your software, and for more detail about the function of every line, you can check in remarques,  we all explained it.

slapos supply ~/srv/project/slapos/software/matomo-tutorial/software.cfg slaprunner
slapos request html5as-1 ~/srv/project/slapos/software/matomo-tutorial/software.cfg

Run the script and check its result

Run the following command at the terminal to compile your software:

# change directory to script
cd ~/srv/project/slapos/software/matomo-tutorial
# give permission to script
chmod 777 ../../../request-matomo-instance.sh
# run the script
../../../request-matomo-instance.sh
# build your software
slapos node software --all

After building, you can find matomo source file in "~/src/project/runner/instance/slappart2/srv/www"
you can use linux command find to check if matomo source file exist:

find ~/srv/project/runner/ -name matomo
Normally, you will get the result like this:
/srv/slapgrid/slappart9/srv/project/runner/software/d4e40d277209ffd7ce9b3a3a21240d12/parts/application/matomo
/srv/slapgrid/slappart9/srv/project/runner/software/d4e40d277209ffd7ce9b3a3a21240d12/parts/application/matomo/vendor/matomo
/srv/slapgrid/slappart9/srv/project/runner/instance/slappart2/srv/www/matomo
/srv/slapgrid/slappart9/srv/project/runner/instance/slappart2/srv/www/matomo/vendor/matomo

The third line is the location of matomo source file.

Check output parameter information

Run the script we added before again:

cd ~/srv/project/slapos/software/matomo-tutorial
../../../request-matomo-instance.sh

Normally, you can find some parameters. But they are not working now because we haven't configure our server and many other things.

So just check if they exist and let's keep going on