Most Powerful Open Source ERP

How To Add a Apache Configuration File

How To Add a Matomo Configuration file to run Apache server
  • Last Update:2022-05-12
  • Version:001
  • Language:en


  1. Create a new apache configuration file 
  2. Edit file "software.cfg"
  3. Edit file ""
  4. The content of file ""
  5. Edit file "buildout.hash.cfg"
  6. Verification

This tutorial will teach you how to add an Apache web server configuration file to make the matomo work normally.


Create a new apache configuration file 

Create file named "" in directory "~/srv/projet/slapos/software/matomo"
How the template file works are same as the matomo configuration template file we added before, slapos will generate a real file in instance according to this template file, and we need to move this real file to a specific directory for it to take effect (this specific path is defined in LAMP).

Edit file "software.cfg"

Add a new keyword for instance of matomo about location of the configuration file, this parameter will be passed to the instance configuration file so that we can use it .

Then add a new download section named "template-apache-httpd", it extends Download-Base section.

context = ....
          key matomo_apache_httpd template-apache-httpd:target
<= matomo-download

Add some parameters needed in file ""

Add some php-configuration and other parameters, those parameters will be passed to the Apache configuration file by keyword context in section [matomo-apache-httpd] we add later
# parameters required by the configuration instance
#php.ini parameters
php.memory_limit = 512M = Europe/Paris
php.upload_max_filesize = 10240M
php.post_max_size = 10240M
php.session.cookie_secure = True
php.max_execution_time = 1800
php.max_input_time = 3600
php.output_buffering = 'Off'
php.max_file_uploads = 100

instance.cli-url = ${apache-php-configuration:url}

Add a recipe section in file ""

Add the receive section for apache configuration file we added.

The output file should be put in ${directory: apache.d}, which has been set as the root directory of the apache configuration file in LAMP. And in variable context we add the section instance-parameter we mentioned before.

recipe = slapos.recipe.template:jinja2
template = {{ matomo_apache_httpd }}
rendered = ${directory:apache.d}/matomo.conf
context =
  section parameter_dict apache-php-configuration

Register the file in "part-list"

To make the configuration file work, we need to register it in keyword part-list of section a new custom-application-deployment in file software.cfg, the content in this section will be read by stack LAMP so the file will be valid.
# give the location of the instance-matomo.cfg fil
# Without it the instance-matomo.cfg file will not be executed
path = ${template-matomo-instance:output}
part-list = matomo-apache-httpd

The content of file ""

<VirtualHost *:{{ parameter_dict['port'] }}>
  DocumentRoot {{ parameter_dict['document-root'] }}/matomo

  SetEnvIf Origin "^http(s)?://(.+\.)?(app\.officejs\.com)$" ORIGIN_DOMAIN=$0
  Header always set Access-Control-Allow-Origin "%{ORIGIN_DOMAIN}e" env=ORIGIN_DOMAIN
  Header always set Access-Control-Allow-Credentials "true" env=ORIGIN_DOMAIN
  Header always set Access-Control-Allow-Headers "Overwrite, Destination, Content-Type, Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control, Authorization" env=ORIGIN_DOMAIN
  Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"

  <Directory {{ parameter_dict['document-root'] }}>
      Options +FollowSymlinks
      AllowOverride All
      Require all granted
      SetEnv HOME {{ parameter_dict['document-root'] }}
      SetEnv HTTP_HOME {{ parameter_dict['document-root'] }}
      Dav off

  ErrorLog "{{ parameter_dict['log-dir'] }}/matomo-error.log"
  CustomLog "{{ parameter_dict['log-dir'] }}/matomo-access.log" combined

You can find all information about apache server configuration in official website of apache

Add an auto-update section

Create a new section in file "buildout.hash.cfg" corresponding to file we added.
filename =
md5sum =

Check output configuration file

Run the command in terminal to rebuild
cd ~/srv/project/slapos/software/matomo
slapos node software --all
slapos node instance --all

Now, there will be a output file "matomo.conf", in path "~/srv/project/runner/slappartX/etc/apache.d/matomo.conf".

This path is been setting as directory of configuration file of apache webrunner in LAMP, so when we put configuration file here, it will work.

X is the slappart where you apache server runs on, if you are not sure, check it with the command

slapos node status
You can use linux command find to check if configuration output file exist:
find ~/srv/project/runner/ -name instance-matomo.cfg
Normally, you will get the result like this:

Normally, we can access the web pages of matomo by browser. Rerun the bash script to get the URL information.

cd ~/srv/project

You will find parameters like these:

{'backend-url': 'https://[2001:67c:1254:102::76fd]:9988/',
 'mariadb-url-list': "['mysql://nextcloud:insecure@']",
 'monitor-base-url': '',
 'monitor-setup-url': '',
 'url': ''}

Copy the url to your browser and you will see the welcome page of matomo.