Docker is one of the simplest and easiest ways to put an application into production. With Docker, we can launch with a few adjustments a Database server, a Proxy with SSL and then Mautic to carry out all Marketing automation campaigns.
Docker Mautic has had more than 2 million downloads over the past 2 years and is the simplest and safest way to get your mautic up and running.
See more about Docker Mautic at Docker Hub: https://hub.docker.com/r/mautic/mautic/
In this article we will create the entire environment to get Mautic up and running using:
The Docker Mautic image was built using the best practices of popular Docker Images on the market to make the perfect environment for Mautic.
The image copies the latest version of Mautic to the /var/www/html folder and configures all necessary permissions on the files.
Along with Mautic we install the Percona MySQL server that has excellent settings for the way in which Mautic works.
Finally, we have a Reverse Proxy that sends requests to Mautic and performs the automatic configuration of SSL with Let's Encrypt and Certbot.
Follow these steps to start using Mautic today:
Enter your password as the email sent from DigitalOcean, if you prefer the unique password.
It's necessary that the machine be “clean,” do not install any other software like Apache, Nginx, or MySQL on this fresh VPS.
The purpose of the installation script (https://github.com/docker/docker-install) is to facilitate quick installation of the latest versions of Docker-CE on supported linux distributions.
In the Terminal of your server type:
curl -fsSL https://get.docker.com -o get-docker.sh sh get-docker.sh
This will automatically install Docker for you on any supported Linux distribution.
To verify that Docker is working, type:
You will see your system information.
Docker allows the entire installation process to be automated. Just run a few commands and the software works with the standard configuration and Mautic is no different.
Before you start, you must add the DNS A or CNAME entry on your domain pointing to the IP address of the VPS server on which Mautic will be running.
The first step is to create an internal network so that Mautic can communicate with the Database and with the Reverse Proxy. In the terminal type:
docker network create mauticnet
We will install the Reverse Proxy called
nginx-proxy next to
nginx-proxy-companion which will be responsible for receiving HTTPs requests and forwarding to Mautic and also creating the free SSL certificate with Let's Encrypt.
In your server's SSH terminal type:
docker run -d --restart=always \ -p 80:80 -p 443:443 --name nginx-proxy \ -v /path/to/certs:/etc/nginx/certs:ro \ -v /etc/nginx/vhost.d \ -v /usr/share/nginx/html \ -v /var/run/docker.sock:/tmp/docker.sock:ro \ --label com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy \ --net=mauticnet \ jwilder/nginx-proxy:latest
Now let's install nginx-proxy-companion which is responsible for Let's Encrypt:
docker run -d --restart=always \ --name nginx-proxy-ssl \ -v /path/to/certs:/etc/nginx/certs:rw \ -v /var/run/docker.sock:/var/run/docker.sock:ro \ --volumes-from nginx-proxy \ --net=mauticnet \ jrcs/letsencrypt-nginx-proxy-companion
You already have an nginx server running SSL without modifying any settings. Docker is fantastic.
The next commands do the work of installing and configuring MySQL and create a root user for us to use with Mautic:
docker volume create mysql_data docker run --name mysql -d -p 3306:3306 \ -e MYSQL_ROOT_PASSWORD=YOURPASSWORD --restart=always \ -v mysql_data:/var/lib/mysql \ --net=mauticnet \ percona/percona-server:5.7 \ --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
Please modify YOURPASSWORD with a strong password.
Finally, we will install Mautic using the official Mautic image that automates the entire installation process:
docker volume create mautic_data docker run -d --restart=always \ --name mautic \ -e MAUTIC_DB_HOST=mysql \ -e MAUTIC_DB_USER=root \ -e MAUTIC_DB_PASSWORD=YOURPASSWORD \ -e MAUTIC_DB_NAME=mautic \ -e VIRTUAL_HOST=mautic.yourdomain.com \ -e LETSENCRYPT_HOST=mautic.yourdomain.com \ -e [email protected] \ -P 8080:80 \ -v mautic_data:/var/www/html \ --net=mauticnet \ --privileged \ mautic/mautic:latest
In the example above, you will need to enter the following variables:
MAUTIC_DB_PASSWORD: Here you must enter the MySQL password.
VIRTUAL_HOST: This is your Mautic's address.
LETSENCRYPT_HOST: You must repeat your Mautic's address;)
LETSENCRYPT_EMAIL: Here is your email to register with Let's Encrypt.
There it is! Now you can visit https://mautic.yourdomain.com.
Article Number: 7
Author: Jul 5, 2022
Last Updated: Jul 5, 2022
Author: David Schargel [[email protected]]
Online URL: https://kb.mautic.org/article/how-to-install-mautic-with-docker-on-digital-ocean.html