Mautic is a marketing automation tool that is free and is the world's largest open source marketing automation project. It enables the implementation of email marketing, lead management software and more.
Mautic allows brands to integrate and customize all their digital properties/channels. With a modern approach to marketing automation, the toolkit helps marketers deliver higher-performing campaigns and content to achieve better results.
In this article, we will explain how to install Mautic on an Ubuntu 20.04 LTS server with NGINX and MariaDB, using Certbot to obtain a free Let's Encrypt certificate for a record.
Requirements or supported versions:
Mautic supports the following versions of PHP depending on its version:
- Mautic 3.0.x through 3.1.x supports PHP 7.2 or 7.3
- Mautic 3.2.x supports PHP 7.2, 7.3 or 7.4
- Mautic 3.3.x supports PHP 7.3 or 7.4
- Mautic 4.0 supports PHP 7.4 (PHP 8.0 is currently only supported by WIP)
- Mautic 4.4 supports PHP 8.0
Only the following database servers are supported:
- Minimum MySQL version 5.7 or MariaDB 10.2 (InnoDB support is required)
Supported web servers:
- Apache version 2.x
- Nginx later than version 1.0 (1.18 recommended)
- Microsoft IIS 7
You can review the official requirements by clicking here.
Installing Mautic
First, you will need to download Mautic, which you can download from the Github official repository:
# wget https://github.com/mautic/mautic/releases/download/4.4.1/4.4.1.zipDownloading the latest version is recommended; you can check it by clicking here.
Then update the repositories and install the web server:
# apt update && apt install -y nginxOnce the web server is installed, extract the file you downloaded into the webroot:
# apt install unzip && mkdir /var/www/mautic && unzip 4.4.1.zip -d /var/www/mautic/Next, change ownership to the web user:
# chown -R www-data:www-data /var/www/mauticYou will also need to install a MySQL server to create the database for Mautic:
# apt install -y mariadb-serverWhen installation is complete, create the database:
# mysql -u root -e "CREATE DATABASE mautic DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci"
Afterward create the user, granting all permissions for the database (remember to change the password for security):
# mysql -u root -e "GRANT ALL ON mautic.* TO 'mauticuser'@'localhost' IDENTIFIED BY 'contraseña'"Install the PHP version compatible with your Mautic version, along with its dependencies:
# apt install php-imagick php7.4-fpm php7.4-mysql php7.4-common php7.4-gd php7.4-imap php7.4-json php7.4-curl php7.4-zip php7.4-xml php7.4-mbstring php7.4-bz2 php7.4-intl php7.4-gmp
Create and edit the file for the website for Mautic:
# nano /etc/nginx/sites-enabled/mauticAdd the following content (remember to change server_name to the record):
server {
listen 80;
listen [::]:80;
server_name mautic.ejemplo.com;
root /var/www/mautic;
error_log /var/log/nginx/mautic.error;
access_log /var/log/nginx/mautic.access;
client_max_body_size 20M;
index index.php index.html index.htm index.nginx-debian.html;
location / {
# try to serve the file directly, fall back to app.php
try_files $uri /index.php$is_args$args;
}
location ~ /(mtc.js|1.js|mtracking.gif|.*\.gif|mtc) {
# default_type "application/javascript";
try_files $uri /index.php$is_args$args;
}
# redirect some entire folders
rewrite ^/(vendor|translations|build)/.* /index.php break;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
location ~* ^/index.php {
# try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 16k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
# Deny everything in the /app directory except bundle Assets
location ~ /app/bundles/.*/Assets/ {
allow all;
access_log off;
}
location ~ /app/ { deny all; }
# Deny everything in the /addons or /plugins directories except bundle Assets
location ~ /(addons|plugins)/.*/Assets/ {
allow all;
access_log off;
}
# location ~ /(addons|plugins)/ { deny all; }
# Deny all php files in the /themes directory
location ~* ^/themes/(.*)\.php {
deny all;
}
# Disable logging for favicon
location = /favicon.ico {
log_not_found off;
access_log off;
}
# Disable logging for robots
location = /robots.txt {
access_log off;
log_not_found off;
}
# Deny access to yml, twig, markdown, init files
location ~* /(.*)\.(?:markdown|md|twig|yaml|yml|ht|htaccess|ini)$ {
deny all;
access_log off;
log_not_found off;
}
# Allow access to the certbot directory to obtain the TLS certificate
location ~ /.well-known/acme-challenge {
allow all;
}
# Deny all attempts to access hidden files/folders such as .htaccess, .htpasswd, .DS_Store (Mac), etc...
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
# Deny all grunt, composer files
location ~* (Gruntfile|package|composer)\.(js|json)$ {
deny all;
access_log off;
log_not_found off;
}
# Deny access to any file with a .php extension in the upload directory
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
# A longer browser cache lifetime can speed up repeat visits
location ~* \.(jpg|jpeg|gif|png|webp|svg|woff|woff2|ttf|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 360d;
}
}Reload the configuration of the web service:
# systemctl reload nginx.serviceAnd install Certbot:
# apt install python3-certbot-nginxFinally, obtain the certificate for the record in question:
# certbot --nginx --redirect -d mautic.ejemplo.comYou can now complete setup with the Wizard included in Mautic for configuration through a web browser using the record in question.
We hope this tutorial has helped you. Have you tried it? Leave us your comments! 🙂
Remember, if you have questions about this or any other issue related to your servers on Clouding, feel free to write to soporte@clouding.io We're here for whatever you need!