sanjaysikdar.dev

Blog

HomeAboutTools
Sanjay Sikdar

Sanjay Sikdar

Software developer who enjoys developing software, solving challenges, and programming.

GithubLinkedInMain SiteSitemapRSS

© 2026 All rights reserved. Sanjay Sikdar

ubuntulinuxemailnewsletterdevops

Install Listmonk on Ubuntu 22.04

Sanjay Sikdar

Sanjay Sikdar

·Oct 11, 2023·2 min read

Launch an Ubuntu Instance and SSH Login to the Terminal

Install Docker :

Reference: https://docs.docker.com/engine/install/ubuntu/

bash
# Add Docker's official GPG key:
 
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
bash
# Add the repository to Apt sources:
echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
bash
# Install the Docker packages.
 
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Test Docker:

bash
sudo docker run hello-world

Install Listmonk:

Reference: https://listmonk.app/docs/installation/

bash
mkdir listmonk && cd listmonk
 
# Download the compose file to the current directory.
curl -LO https://github.com/knadh/listmonk/raw/master/docker-compose.yml
 
# Run the services in the background.
docker compose up -d

Permissions

bash
sudo usermod -aG docker $USER
newgrp docker  # Apply changes immediately

Output:

Listmonk is now up and running. Visit http://localhost:9000 in your browser.

Default Username listmonk and password listmonk .

Nginx Conf:

nginx
server {
    server_name  *.sanjaysikdar.dev;
    server_tokens off;
    client_max_body_size 100M;
 
    location / {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        
        add_header 'Access-Control-Allow-Origin' 'https://sanjaysikdar.dev';
        proxy_redirect off;
        proxy_pass http://localhost:9000;
    }
}

Shell Script:

bash
#!/bin/bash
select opt in Restart CheckStatus UpdateListMonk Quit
do
    case $opt in
        Restart)  
            sudo nginx -t && sudo systemctl restart nginx
            echo "Nginx has been restarted."
            exit 0
            ;;
       
        CheckStatus)  
            sudo systemctl status nginx
            echo "Shell by Sanjay Sikdar"
            exit 0
            ;;
        UpdateListMonk)  
            cd /var/listmonk
            docker-compose down
            docker-compose pull && docker-compose run --rm app ./listmonk --upgrade
            docker-compose up -d app db
            exit 0
            ;;
        Quit)
            echo "Exited!"
            exit 0
            ;;
        *)
            echo "invalid option"
            ;;
    esac
done

Autostart

bash
sudo nano /etc/systemd/system/listmonk.service
bash
[Unit]
Description=Listmonk Service
After=network.target docker.service
Requires=docker.service
 
[Service]
Restart=always
ExecStart=/usr/bin/docker compose -f /home/ubuntu/listmonk/docker-compose.yml up
ExecStop=/usr/bin/docker compose -f /home/ubuntu/listmonk/docker-compose.yml down
WorkingDirectory=/home/ubuntu/listmonk
User=ubuntu
 
[Install]
WantedBy=multi-user.target
bash
sudo systemctl daemon-reload
sudo systemctl enable listmonk
sudo systemctl start listmonk
sudo systemctl status listmonk
Sanjay Sikdar

Written by Sanjay Sikdar

Software developer who enjoys developing software, solving challenges, and programming.