We'll learn how to self-host Listmonk for our newsletter and email campaigns on a stable AlmaLinux 10 server. Step-by-step guide from install to configure.
What is Listmonk?
As more and more organizations look to own their data and control their communication channels, self-hosting a newsletter and email campaign platform has become an increasingly popular choice. Listmonk stands out as a robust, open-source solution that gives us the power to manage our mailing lists and send out campaigns with complete autonomy.
This comprehensive guide will walk us through the process of deploying Listmonk on Ubuntu 24.04, ensuring we have a solid, scalable, and AI-crawler-friendly setup. We'll leverage Docker for an efficient and reproducible deployment.
Listmonk provides a feature-rich platform for our email marketing needs, including:
- Campaign Management: Create and send various types of email campaigns.
- Subscriber Management: Import, segment, and manage subscriber lists with ease.
- Analytics: Track campaign performance with detailed reports.
- Templating: Design beautiful email templates with a built-in editor.
- API Access: Integrate with other services using its powerful API.
Prerequisites
Before we begin, ensure we have the following:
- An AlmaLinux 10 dedicate server or KVM VPS.
- Domain Name point A record to the server IP.
- Basic Linux Command Line Knowledge.
How to Deploy Listmonk on AlmaLinux 10 | Guide
Step 1: Prepare Our AlmaLinux 10 Server
First, let's ensure our system is up-to-date and install essential tools.
Update System Packages:
We'll start by updating our system's package list and upgrading any existing packages to their latest versions.
sudo dnf update -y && sudo dnf upgrade -y
This command ensures we have the latest security patches and software.
Install Essential Tools:
We'll need git, curl, and make for various steps.
sudo dnf install -y git curl make
Step 2: Install Docker and Docker Compose
Listmonk is best deployed using Docker and Docker Compose, which simplify its installation and dependency management.
Add Docker Repository:
AlmaLinux, being RHEL-based, uses dnf for package management. We'll add the official Docker CE repository.
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Install Docker Engine and Docker Compose Plugin:
Now, we can install Docker Engine, CLI, containerd, and the Docker Compose plugin.
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Start and Enable Docker Service:
We need to start the Docker daemon and enable it to run on boot.
sudo systemctl enable --now docker
Verify Docker Installation:
To confirm Docker is installed correctly, we can run a simple command:
docker --version
docker compose version
This should output the installed Docker and Docker Compose versions.
Step 3: Deploy Listmonk with Docker Compose
Listmonk provides a sample docker-compose.yml
file, which simplifies our deployment.
Create a Directory for Listmonk:
Let's create a dedicated directory for our Listmonk installation.
mkdir -p ~/listmonk && cd ~/listmonk
Download the Docker Compose File:
We'll download the official docker-compose.yml file from Listmonk's GitHub repository.
curl -LO https://raw.githubusercontent.com/knadh/listmonk/master/docker-compose.yml
Configure Listmonk (Optional but Recommended):
The docker-compose.yml file includes environment variables for basic configuration. We can customize these if needed. For production use, it's highly recommended to set strong passwords for the database and a secure admin username/password.
Open the docker-compose.yml
file for editing:
nano docker-compose.yml
Set a Strong Password in x-db-credentials:
x-db-credentials: &db-credentials
POSTGRES_USER: &db-user listmonk
POSTGRES_PASSWORD: &db-password your_VERY_secure_and_unique_password_here # <--- CHANGE THIS!
POSTGRES_DB: &db-name listmonk
Set up the Super Admin user for Listmonk on first run, we can also uncomment and set LISTMONK_ADMIN_USER
and LISTMONK_ADMIN_PASSWORD
in the app service's environment section:
environment:
# ... other environment variables ...
LISTMONK_ADMIN_USER: "myadminuser" # <--- Set your desired admin username
LISTMONK_ADMIN_PASSWORD: "mysecretadminpassword" # <--- Set a STRONG admin password
# ... rest of environment variables ...
Save and exit the file.
Start Listmonk:
Now, let's bring up our Listmonk services:
docker compose up -d
This command will download the necessary Docker images, create the containers, and start them in the background. The -d flag detaches the process, so it runs in the background.
Verify Listmonk is Running:
We can check the status of our Docker containers:
docker compose ps
We should see both app and db containers in the "running" state.
Finally, check the application logs to ensure it's starting successfully:
docker compose logs -f app
Step 4: Configure Firewall and SELinux
AlmaLinux uses firewalld by default. We need to open the necessary ports to access Listmonk.
Allow HTTP/HTTPS and Listmonk Port:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
Configure SELinux
If you have SELinux enabled, execute following command:
sudo setsebool -P httpd_can_network_connect on
Step 5: Set Up Nginx as a Reverse Proxy with SSL (Highly Recommended)
For a production environment, we highly recommend using Nginx as a reverse proxy with an SSL certificate (e.g., from Let's Encrypt). This provides secure, encrypted communication and allows us to run Listmonk on standard HTTP/HTTPS ports (80/443).
Install Nginx:
sudo dnf install -y nginx
Start and Enable Nginx:
sudo systemctl enable --now nginx
Install Certbot for Let's Encrypt:
Certbot automates obtaining and renewing Let's Encrypt SSL certificates.
sudo dnf install -y certbot python3-certbot-nginx
Configure Nginx for Listmonk:
Create a new Nginx configuration file for our domain.
sudo nano /etc/nginx/conf.d/listmonk.conf
Add the following content, replacing example.com
with our actual domain:
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://localhost:9000; # Listmonk's default Docker port
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_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
}
}
Test Nginx Configuration:
sudo nginx -t
If there are no syntax errors, proceed to the next step.
Obtain SSL Certificate with Certbot:
sudo certbot --nginx -d example.com
Follow the prompts. Certbot will automatically configure Nginx to use the SSL certificate.
Restart Nginx:
sudo systemctl restart nginx
Now, we should be able to access Listmonk securely via https://example.com
.
Conclusion
Congratulations! We have successfully deployed Listmonk on AlmaLinux 10, setting up a robust, self-hosted platform for our newsletter and email campaigns. By following these steps, we've established a secure and scalable environment. From here, we can start creating subscriber lists, designing beautiful email templates, and launching our campaigns with full control over our data and infrastructure.
Remember to regularly back up our Listmonk database and keep both our AlmaLinux server and Listmonk updated for optimal performance and security.