How to host Matomo on AWS Lightsail VM Instance - ServerAvatar

Published : Aug 28, 2023

Share This Post

cloud-platform

AWS Lightsail

AWS Lightsail is a simplified and cost-effective way to launch and manage virtual private servers (VPS) in the cloud. It provides a user-friendly interface for deploying and scaling VPS instances with pre-configured options for operating systems, applications, and storage. Additionally, it offers a predictable pricing model that includes a flat monthly fee based on the instance size and data transfer limits.

Get started with AWS Lightsail
application

Matomo

Matomo means honesty in Japanese. Matomo(formerly Piwik) is a free and open-source web analytics platform that helps to analyse website traffic. Matomo allows website owners or administrators to collect, analyse, and visualize data about visitors and interactions. It is the most popular alternative to Google Analytics or Tableau. It provides more features unavailable on prestigious tools like Google Analytics, such as Self-hosting, Data Privacy, Customization, and Scalability E-commerce Analytics.

More info

Create VM Instance in AWS Lightsail

To create a server in AWS Lightsail, First log in to the AWS Lightsail console. Once you are there, Follow the steps given below.

Step 1: Go to Instance Creation Form

To access the instance creation form, Go to AWS Lightsail dashboard and click on the orange button with Create Instance text. See the following image for reference.

Create VM Instance in AWS Lightsail - Step 1

Step 2: Select the Location of your Instance

First of all, You have to select the location for your instance. It is always better to select a location closest to your major traffic source. It will decrease the latency for majority of your website visitors.

Create VM Instance in AWS Lightsail - Step 2

If you want to change the location of your server, You can simply update the current region in your AWS account.

Step 3: Select the OS for your Instance

After selecting the location, Select the operating system for your instance. In this case, First click on OS Only and then select Ubuntu 20.04 as an operating system just like the following image.

Create VM Instance in AWS Lightsail - Step 3

Step 4: Select SSH Key and Launch Script (Optional/Advanced)

This is an optional step. Here you can set the Launch script and the main SSH key for your server. If you don't understand launch script and SSH keys, Just ignore this step.

Create VM Instance in AWS Lightsail - Step 4

Step 5: Select the Plan

In this step, select the size of your VM instance. AWS Lightsail provides lots of different options when it comes to plans and pricing. The plan and pricing selection completely depends on the requirements of your site(s). So, select the plan based on the complexity and traffic of your sites.

Create VM Instance in AWS Lightsail - Step 5

Step 6: Verify and Create the Instance

Finally, Enter the name of your instance, number of instances you want to create and assign the tags accordingly for identification. Once done, click on the Create Instance button to start the instance creation process.

Create VM Instance in AWS Lightsail - Step 6

It might take a few minutes to deploy the instance. Once done, follow the below given step to update the firewall rules for the VM instance.

Step 7: Update Firewall Rules

ServerAvatar requires 43210 port open. In total, You need to keep the following ports open on the instance.

  • 22 (SSH): To access your server via SSH.
  • 80 (HTTP): To access your sites on HTTP.
  • 443 (HTTPS): To access your sites on HTTPS.
  • 43210 (ServerAvatar): To allow communication between ServerAvatar and your instance.

To update the firewall rules for a specific instance, Go to the AWS Lightsail dashboard and click on the name of the instance you want to update. Then go to the Networking section and add the missing firewall rules. After updating the firewall rules, the networking section of your Instance should look like the following image.

Create VM Instance in AWS Lightsail - Step 7

Initial Server Configuration

The Initial server configuration includes installation and configuration of various packages required to host your website. Usually, You have to write commands and modify configuration files. Luckily, With ServerAvatar, Your full server configuration and optimisation can be automated.

Here are the three ways to automatically configure your server with ServerAvatar.

Install and Setup Matomo on Cloud using ServerAvatar

Step1: Create Matomo Database

The Matomo installation process requires database Credentials. So, to create a MySQL database for Matomo, Access the Database tab on the ServerAvatar server panel to create a Database.

image

To create a Database, Enter the details, such as the Database Name, in the database creation form like the image below.

image

Database successfully created.

Steps 2: Create PHP Application

Access the Applications tab from the server panel to create a new PHP application for Matomo.

image

Now fill up the required details in the application form, as seen in the image below.

image

Note that:

If you want to host Matomo on your domain, then make sure to point your domain to the current IP address of your server, and for that:

  1. Log in to your domain provider site, where you buy your domain. Click here for more info about your domain name.
  2. Access DNS Manager to edit your DNS records (contact the support team if you don’t find them)
  3. Change the IP address of A Record of your website to the > current server’s IP address.

To host Matomo on your subdomain, for example, matomo.yourdomain.com, create a new application with the subdomain as your primary domain and follow the same procedure. For accessing Matomo on the subdomain, you need to add your subdomain on A Record that points to the current IP address of your server. To point to an IPV6 address, you would need to use an AAAA record.

Click to Next Step.

Now, choose the method and service provider: Git and GitHub (follow as per the snapshot).

image

Continue the process by entering the necessary information as provided below:

Repository Type: Public
Clone HTTPS URL: https://github.com/matomo-org/matomo.git
Branch: 5.x-dev
Deployment script:

composer install;

image

Proceed by clicking the "Next Step".

You can either create a new System User or select an existing one.

image

Next, choose PHP version 7.2 or above. For the custom Webroot, keep the field empty, as shown in the provided snapshot, as we're specifically seeking "index.php" or "index.html" within the custom setup.

Custom Webroot: (keep this field empty)

image

Proceed to the next steps and ensure your details and requirements are accurately entered.

After confirming, click on Create Application to initiate the application creation process.

STEP 3: Install and Setup Matomo

Now access the site URL from the Application panel to install and set up Matomo.

MATOMO INSTALLER

The welcome message screen is displayed upon accessing the URL, as depicted in the snapshot.

image

Click next to process further with the system check tab, which will open where you have two options: copy the system check or download the system check. According to your convenience, save or save system check. It is essential to keep it with you in case Matomo support team asks you for this information.

image

DATABASE SETUP

We have already created a database for Matomo in step 1. To establish a connection between the database and the application, enter the database credential we have already made. You can access all your database credentials, like database name, username, and password, by accessing the database tab from the server panel.

Enter the following database credential we have already created in ServerAvatar:

Login: Username of database
Password: Database password
Database Name: Database name

image

Process further by click on Next.

CREATE SUPERUSER

We have successfully configured the database with Matomo. Now, we create a superuser to log into Matomo after successfully installing and setting up Matomo.

To create superuser, enter the following details:

Superuser login: dharmilshiroya
Password: yourpassword
Password (Repeat): yourpassword
Email: dharmilshiroya2456@gmail.com

Please remember the credentials you entered above for logging into MATOMO.

image

SET UP THE WEBSITE THAT YOU WOULD LIKE TO ANALYZE

Now, Enter the details of the websites you would like to track or analyze with Matomo. For example, I have tried to track and analyze the website URL on which we deploy the Matomo. Please enter your website URL and the name you want to analyze. Here, Matomo provides the advanced option for you who want to use it to analyze e-commerce websites (E-commerce enabled) or Others. If your website is on E-commerce, select E-commerce enable in the E-commerce menu, as seen in the snapshot.

image

We had set up a website that you like to track and analyze. We have almost completed the setup process.

The next step is JavaScript tracking code. Do not change anything in the code. Just click on next.

We have successfully installed and set up Matomo on the Server through ServerAvatar. You can see a congratulatory message on your screen.

image

Now, log in to Matomo using the superuser credentials we created for the superuser. Please enter the credentials that you provided.

image

We have successfully deployed Matomo on Server on ServerAvatar.

Tip:- It will run on HTTP, but to run it on HTTPs ServerAvatar provides a one-click solution to switch to HTTPs for that, go to the SSL Certificate in the application panel and click on force HTTP to HTTPs.