Matomo is an open-source web analytics platform, which provides you a complete control over your data. It is a great alternative to Google Analytics. It helps you to gather all the significant information about the users of your website.
You can track key performance indicators, including goal conversion rates and the number of visits, efficiently. In this article, you will find the step by step guideline for installing it on Ubuntu 18.04. But before that, let’s take a look at the requirements.
Requirements for Installing Matomo on Ubuntu 18.04
- PHP 5.5.9 or greater version
- MySQL 5.5 or greater version
- MariaDB (alternative to MySQL)
- Web servers, like Apache, Nginx, IIS etc.
- PHP extension pdo and pdo_mysql, or the MySQL extension
Installing Matomo on Ubuntu 18.04
- Install PHP with all the required extensionby using the following command:
sudo apt-get install php php-fpm php-curl php-gd php-cli php-mysql php-xmlphp-mbstring
- Now, you have to install the database. As stated earlier, you have two options – MySQL or MariaDB.Here, we will be using the latter one. Follow the steps mentioned here for installing MariaDB.
- Sign into MySQL shell as root user.
$ mysql -u root -p
- Create a database and user. Grant all privileges.Step 4: Create a database and user. Grant all privileges.
CREATEDATABASE matomo; GRANT ALL PRIVILEGESON matomo.* TO'matomo'@'localhost'IDENTIFIEDBY"StrongPassword"; FLUSHPRIVILEGES; Quit
- Get the newest version of Matomo.
$ wget https://builds.piwik.org/piwik.zip
- Unzip the downloaded file.
$ unzip piwik.zip
- Move piwik directory to /srv/.
$ sudo mv piwik /srv/matomo/
- Get nginx.
$ sudo apt-get install nginx
- Create nginx configuration file for the analytics platform.
$ sudo vim /etc/nginx/conf.d/matomo.conf
- Insert the following lines in the configuration file:
server { listen80; root /srv/matomo; index index.php index.html; access_log /var/log/nginx/matomo_access.log; error_log /var/log/nginx/matomo_error.log; server_name stats.example.com www.stats.example.com; client_max_body_size100M; location / { try_files$uri /index.php?$query_string; } location~ .php$ { include /etc/nginx/fastcgi_params; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } }
Make sure that the values of server_name and fastcgi_pass match with your existing settings.
- Now, change the ownership of Matomo directory.
$ sudo chown -R www-data:www-data /srv/matomo/
- Restart and enable nginx.
$ sudo systemctl restart nginx $ sudo systemctl enable nginx
- Open your favorite browser. Go to http://stats.example.com.
- You will see a welcome page. Click “Next.”
- You will see a System Check page. Make sure that all the system checks have been passed. Click “Next.”
- The Database Setup page will appear. Use the following credentials:
Database Server : 127.0.0.1 Login: matomo Password: <StrongPassword> Database Name: matomo Adapter: PDO/MYSQL
- If you have used the credentials correctly, you will see a success message for creating tables. Click “Next.”
- Now, you have to create a superuser. Insert your desired username, password, and email ID.
- Next, you have to set up your website. Insert your website name, URL and time zone. You can either enable or disable e-commerce option.
- You will see a congratulations page. Basically, it tells you that the installation of Matomo has been completed successfully.
You will be provided with a JavaScript tracking code. You should copy and save it for later use. Next, you will see a login page. Enter your username and password correctly to get into Matomo.
Conclusion:
In this article, you have learned the steps for installing Matomo on Ubuntu 18.04 web hosting. Now, you can perform a wide range of functions, including tracking goals and making e-commerce orders.
Check out these top 3 Linux hosting services
- Click here to know more about the Best website hosting.