Installing Countly Community Edition on Debian Latest

Countly is an open-source, mobile and web analytics platform that offers real-time insights into the usage of your applications. In this tutorial, we will guide you through the process of installing Countly Community Edition on Debian Latest.

Prerequisites

  • A server running Debian Latest.
  • Access to a terminal with sudo privileges.
  • A domain name pointing to your server's IP address.

Step 1: Update the System

Connect to your Debian server using SSH and update the system.

sudo apt-get update && sudo apt-get upgrade

Step 2: Install Required Dependencies

Before we can install Countly, we need to install some required dependencies. Run the following command to install these dependencies:

sudo apt-get install build-essential git-core curl libssl-dev libfontconfig1 fontconfig

Step 3: Install MongoDB

Countly requires MongoDB as the backend database. Run the following commands to install MongoDB:

sudo apt-get install mongodb

sudo systemctl start mongodb

Step 4: Install Node.js

Countly is based on Node.js, an open-source Javascript runtime environment. Run the following commands to install Node.js and npm:

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -

sudo apt-get install -y nodejs

sudo apt-get install -y npm

Step 5: Install Countly

Now, let's install Countly Community Edition. Clone the Countly repository from the official GitHub repository using the following command:

git clone https://github.com/Countly/countly-server.git

After cloning the repository, go to the Countly directory and run the following commands:

cd countly-server

npm install --production

Step 6: Configure Countly

To configure Countly, we first need to create a configuration file. Create a new file called config.js in the Countly directory using the following command:

sudo nano config.js

Copy and paste the following configuration into the file:

module.exports = {
    mongodb: {
        server: "localhost",
        port: 27017,
        db: "countly",
        max_pool_size: 500,
        check_delay: 5000,
        retries: 5,
        ssl: false
    },
    api: {
        workers: 0,
        port: 3001,
        host: "localhost",
        safe: true,
        session_duration_limit: 120,
        max_sockets: 1024
    },
    path: "",
    logging: {
        info: ["jobs", "dashboard", "push", "checklist", "dashboard_geo", "assistant"],
        default: "warn",
        console: "info",
        audit: "none"
    },
    apps: {},
    plugins: {
        path: "../plugins",
        list: {
            "push": {
                "path": "../plugins/push/api/push",
                "options": {
                    "i": "0",
                    "type": "gcm",
                    "apiKey": "",
                    "projectNumber": ""
                }
            }
        }
    },
    frontend: {
        port: 6001,
        host: "localhost",
        use_cdn: true,
        cdn_path: ""
    },
    fileStorage: {}
};

Save the file and exit the editor.

Next, we need to make sure that Countly is accessible from the internet. Open the Countly configuration file using the following command:

sudo nano /etc/nginx/sites-available/default

Add the following block of code to the end of the file:

server {
    listen 80;
    listen [::]:80;
    server_name your-domain.com;
    location / {
        proxy_pass http://localhost:6001/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

Replace your-domain.com with your domain name. Save the file and exit the editor.

Restart Nginx to apply the changes:

sudo systemctl restart nginx

Step 7: Start Countly

Finally, start Countly by running the following command in the Countly directory:

COUNTLY_CONFIG=./config.js npm start

You can now access the Countly dashboard by visiting http://your-domain.com.

Conclusion

You have successfully installed Countly Community Edition on your Debian Latest server. Countly is a powerful analytics tool that provides real-time insights into the usage of your applications. With Countly, you can track user behaviour, device metrics and other key performance indicators to make informed decisions about your applications.