|
|
|
## Prerequisites
|
|
|
|
For Matomo(Piwik) you need to install LAMP-stack before installing Matomo. I installed:
|
|
|
|
* apache2
|
|
|
|
* mariadb-server mariadb-client
|
|
|
|
* php7.2 libapache2-mod-php7.2 php7.2-common php7.2-sqlite php7.2-curl php7.2-intl php7.2-mbstring php7.2-xmlrpc php7.2-mysql php7.2-gd php7.2-xml php7.2-cli php7.2-zip
|
|
|
|
|
|
|
|
I installed Matomo in Ubuntu 16.04 Virtual Machine on Google Cloud.
|
|
|
|
|
|
|
|
## Installation steps
|
|
|
|
|
|
|
|
### Apache2
|
|
|
|
```
|
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install apache2
|
|
|
|
```
|
|
|
|
Then we need to enable apache2
|
|
|
|
```
|
|
|
|
sudo systemctl stop apache2.service
|
|
|
|
sudo systemctl start apache2.service
|
|
|
|
sudo systemctl enable apache2.service
|
|
|
|
```
|
|
|
|
### Maria/MySQL database
|
|
|
|
```
|
|
|
|
sudo apt-get install mariadb-server mariadb-client
|
|
|
|
```
|
|
|
|
Enable and start database:
|
|
|
|
```
|
|
|
|
sudo systemctl stop mysql.service
|
|
|
|
sudo systemctl start mysql.service
|
|
|
|
sudo systemctl enable mysql.service
|
|
|
|
```
|
|
|
|
Install database by running:
|
|
|
|
```
|
|
|
|
sudo mysql_secure_installation
|
|
|
|
```
|
|
|
|
Installation will ask these answer following:
|
|
|
|
* Enter current password for root (enter for none): Just press the Enter
|
|
|
|
* Set root password? [Y/n]: Y
|
|
|
|
* New password: Enter password
|
|
|
|
* Re-enter new password: Repeat password
|
|
|
|
* Remove anonymous users? [Y/n]: Y
|
|
|
|
* Disallow root login remotely? [Y/n]: Y
|
|
|
|
* Remove test database and access to it? [Y/n]: Y
|
|
|
|
* Reload privilege tables now? [Y/n]: Y
|
|
|
|
|
|
|
|
Test that you can login:
|
|
|
|
```
|
|
|
|
sudo mysql -u root -p
|
|
|
|
```
|
|
|
|
### PHP
|
|
|
|
|
|
|
|
Run these to update PHP to PHP7.2
|
|
|
|
```
|
|
|
|
sudo apt-get install software-properties-common
|
|
|
|
sudo add-apt-repository ppa:ondrej/php
|
|
|
|
```
|
|
|
|
Update
|
|
|
|
```
|
|
|
|
sudo apt-get update
|
|
|
|
```
|
|
|
|
Install modules:
|
|
|
|
```
|
|
|
|
sudo apt install php7.2 libapache2-mod-php7.2 php7.2-common php7.2-sqlite php7.2-curl php7.2-intl php7.2-mbstring php7.2-xmlrpc php7.2-mysql php7.2-gd php7.2-xml php7.2-cli php7.2-zip
|
|
|
|
```
|
|
|
|
We need to make some changes in the configuration file in /etc/php/7.2/apache2/php.ini :
|
|
|
|
|
|
|
|
file_uploads = On
|
|
|
|
allow_url_fopen = On
|
|
|
|
short_open_tag = On
|
|
|
|
memory_limit = 256M
|
|
|
|
upload_max_filesize = 100M
|
|
|
|
max_execution_time = 360
|
|
|
|
date.timezone = Europe/Helsinki
|
|
|
|
|
|
|
|
Save changes and close the file. You need to restart Apache to make the changes:
|
|
|
|
```
|
|
|
|
sudo systemctl restart apache2.service
|
|
|
|
```
|
|
|
|
### Create database
|
|
|
|
|
|
|
|
Login to your database:
|
|
|
|
```
|
|
|
|
sudo mysql -u root -p
|
|
|
|
```
|
|
|
|
Then we are creating database called matomo:
|
|
|
|
```
|
|
|
|
CREATE DATABASE matomo;
|
|
|
|
```
|
|
|
|
Then we create user called matomouser and set password for it:
|
|
|
|
```
|
|
|
|
CREATE USER 'matomouser'@'localhost' IDENTIFIED BY 'new_password_here';
|
|
|
|
```
|
|
|
|
We need to grant access to the created database for the new user:
|
|
|
|
```
|
|
|
|
GRANT ALL ON matomo.* TO 'matomouser'@'localhost' IDENTIFIED BY 'user_password_here' WITH GRANT OPTION;
|
|
|
|
```
|
|
|
|
To make the changes:
|
|
|
|
|
|
|
|
```
|
|
|
|
FLUSH PRIVILEGES;
|
|
|
|
EXIT;
|
|
|
|
```
|
|
|
|
### Matomo
|
|
|
|
|
|
|
|
Downloading Matomo files:
|
|
|
|
```
|
|
|
|
cd /tmp && wget https://builds.matomo.org/piwik.zip
|
|
|
|
unzip piwik.zip
|
|
|
|
sudo mv piwik /var/www/html/matomo
|
|
|
|
```
|
|
|
|
We need to change the files permissions to use them:
|
|
|
|
```
|
|
|
|
sudo chown -R www-data:www-data /var/www/html/matomo/
|
|
|
|
sudo chmod -R 755 /var/www/html/matomo/
|
|
|
|
```
|
|
|
|
#### Configure apache2 Matomo site
|
|
|
|
|
|
|
|
We will make now our Matomo page visible using apache2. In file /etc/apache2/sites-available/matomo.conf :
|
|
|
|
```
|
|
|
|
<VirtualHost *:80>
|
|
|
|
ServerAdmin admin@example.com
|
|
|
|
DocumentRoot /var/www/html/matomo
|
|
|
|
ServerName example.com
|
|
|
|
|
|
|
|
<Directory /var/www/html/matomo/>
|
|
|
|
Options FollowSymlinks
|
|
|
|
AllowOverride All
|
|
|
|
Require all granted
|
|
|
|
</Directory>
|
|
|
|
|
|
|
|
ErrorLog ${APACHE_LOG_DIR}/error.log
|
|
|
|
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
|
|
|
|
|
|
|
</VirtualHost>
|
|
|
|
```
|
|
|
|
Change the ServerName to your server. Save file and exit.
|
|
|
|
|
|
|
|
Enable the site:
|
|
|
|
```
|
|
|
|
sudo a2ensite matomo.conf
|
|
|
|
sudo a2enmod rewrite
|
|
|
|
sudo systemctl restart apache2.service
|
|
|
|
```
|
|
|
|
Now you should see Matomo Installation page while browsing http://your-host
|
|
|
|
|
|
|
|
Set-up your Database settings. If you are running database in the same host set database server 127.0.0.1. In login add the database user we created earlier: matomouser and matomo database. Then create a superuser.
|
|
|
|
|
|
|
|
### Tracking sites
|
|
|
|
To track websites you need to inject a javascript-code to your hosted website. We injected your code in GitLab.
|
|
|
|
In gitlab.rb configuration file add the matomo-server url and site id which is 1 in your first webpage.
|
|
|
|
```
|
|
|
|
gitlab_rails['extra_piwik_url'] = 'your-matomo-ip'
|
|
|
|
gitlab_rails['extra_piwik_site_id'] = '1'
|
|
|
|
```
|
|
|
|
Then run reconfigure:
|
|
|
|
```
|
|
|
|
sudo gitlab-ctl reconfigure
|
|
|
|
```
|
|
|
|
Now you should have data in your Matomo!
|
|
|
|
|