How to Install Listmonk on Ubuntu Server Latest

Listmonk is an open source email newsletter solution that allows you to easily create and manage email campaigns. In this tutorial, we will walk you through the step-by-step process of installing Listmonk on Ubuntu Server Latest.

Prerequisites

Before you begin the installation process, make sure that you have the following:

Step 1 — Installing Required Packages

Before installing Listmonk, we need to make sure that all the required packages are installed on our Ubuntu server.

To begin, update the Ubuntu package index:

sudo apt-get update

Once the update is complete, install the required packages:

sudo apt-get install -y git curl libmariadb-dev mariadb-client mariadb-server

Step 2 — Installing Go

Listmonk is developed using the Go programming language, so we need to install it on our server.

First, we will download the Go binary:

curl -O https://storage.googleapis.com/golang/go1.17.2.linux-amd64.tar.gz

Once the download is complete, extract the archive to the /usr/local directory:

sudo tar -xf go1.17.2.linux-amd64.tar.gz -C /usr/local

We need to add the Go binary to the system’s PATH environment variable by updating the .bashrc file:

echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc

Step 3 — Setting Up MySQL/MariaDB

We will use a MySQL/MariaDB database management system to store Listmonk data.

First, we will install the database server:

sudo apt-get install -y mariadb-server

Once installed, start the database service and enable it to start at boot:

sudo systemctl start mariadb
sudo systemctl enable mariadb

Next, we will secure the installation by executing the mysql_secure_installation script:

sudo mysql_secure_installation

The script will ask for the root password, which is not set by default. Press Enter to continue and set the root password.

Then, answer the additional questions to secure the installation by enabling a password policy, removing anonymous users, or restricting remote access.

Next, we will create a new database and a database user for Listmonk:

sudo mysql -u root -p

Enter the root password and execute the following MySQL commands:

CREATE DATABASE listmonk CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER listmonk@localhost IDENTIFIED BY 'new_password_here';
GRANT ALL PRIVILEGES ON listmonk.* TO listmonk@localhost WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

Replace new_password_here with a strong password of your choice.

Step 4 — Installing Listmonk

We will now clone the Listmonk repository from GitHub and compile the executable.

First, create a new directory for Listmonk:

mkdir ~/listmonk && cd ~/listmonk

Then, clone the repository:

git clone https://github.com/knadh/listmonk.git .

Compile the executable using the go command:

go build

This will create an executable file called listmonk.

Step 5 — Configuring Listmonk

To configure Listmonk, we need to create a configuration file called config.yml.

Create the file using a text editor:

nano ~/listmonk/config.yml

Then, copy and paste the following content into the file:

database:
  dialect: mysql
  conn: listmonk:new_password_here@/listmonk?parseTime=true&multiStatements=true&sql_mode=strict_trans_tables,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

server:
  addr: 0.0.0.0:9000

logs:
  dir: logs/
  level: info
  formatter: text

storage:
  s3:
    endpoint: ""
    bucket: ""
    region: ""
    access_key: ""
    secret_key: ""
    secure: true
    cdn_url: ""

smtp:
  host: ""
  port: 587
  username: ""
  password: ""
  fromname: ""
  from: ""
  replyto: ""

hashids:
  salt: ""

signup:
  confirm_url: ""
  welcome_email:
    subject: ""
    body: ""

google_oauth2:
  client_id: ""
  client_secret: ""
  redirect_url: ""
  scopes: ""
  state: ""

facebook_oauth2:
  client_id: ""
  client_secret: ""
  redirect_url: ""
  state: ""

twitter_oauth1:
  consumer_key: ""
  consumer_secret: ""
  access_token: ""
  access_secret: ""

jwt:
  secret: "change-this"

public_static_dir: "public/"
templates_dir: "templates/"

Update the following fields in the configuration file:

Save and close the file.

Step 6 — Running Listmonk

After the installation and configuration, we can now start using Listmonk by running the listmonk executable.

Start the Listmonk server:

./listmonk serve

This will start the server on port 9000.

You can now access Listmonk by visiting http://your-server-ip:9000 in a web browser.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!