Installing Mautic – Free Marketing Automation

Digital marketing is a great way to grow your business and drive people to your website. However, tracking your progess is a daunting task without the help of market automation tools. One such tool is the open source Mautic. This guide will walk through the steps necessary to setup a basic Mautic (v2.0.0) installation on a DigitalOcean droplet and connect it to a WordPress website.

We will be building on top of a LEMP server, so if you don’t already have a your server setup, have a look at this guide about building up a basic LEMP stack.

Customize this Guide

There are a few portions of this guide that you will probably want to customize. If you modify the values here, the commands below will be customized for your installation and you will be able to copy/run the commands without the need for modification.

Database Name:

Database User:

Database Password:

Website Name (internal):

Site Domain Name:

Create the Mautic Database

First we will log into MySQL/MariaDB and create the database that will be used by Mautic. Additionally, we will create a dedicated user for Mautic and grant it privileges on the new database.

mysql -uroot -p

CREATE DATABASE ;
GRANT ALL PRIVILEGES ON .* TO ''@'localhost' IDENTIFIED BY '';
FLUSH PRIVILEGES;
\q

Preparing PHP

Assuming you already have a PHP 7.0 installation, you just need to make sure you have all the PHP extensions needed by Mautic. If you have not already configured PHP-FPM, you may want to refer back to my LEMP server guide.

sudo apt-get -y install php7.0-fpm php7.0-cli php7.0-json php7.0-curl php7.0-gd php7.0-mysqlnd php7.0-imap php7.0-mcrypt php7.0-mbstring php7.0-xml php7.0-zip php7.0-intl

sudo nano /etc/php/7.0/fpm/php.ini

date.timezone = "America/Chicago"
memory_limit = 256M

sudo service php7.0-fpm restart

Install Mautic

Composer is an application-level package manager that Mautic will use as part of it’s setup process. Once Composer is installed we will clone the 2.0.0 branch of Mautic directly from the source code hosted on Github. Once the clone is complete we’ll install via Composer.

sudo apt-get install -y curl
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

sudo mkdir -p /srv/http//{public_html,logs}
sudo git clone https://github.com/mautic/mautic.git /srv/http//public_html
cd /srv/http//public_html
git tag -l
sudo git checkout tags/2.2.1
sudo chown -R $(whoami):www-data /srv/http//public_html

sudo apt-get install -y unzip
composer install

Configure Nginx

Now edit your Nginx config for your Mautic site. The config here builds upon the config created in my LEMP server guide.

sudo nano /etc/nginx/sites-available/

server {
listen 80;
server_name ;
return 301 https://$host$request_uri;
}

server {
listen 443 ssl;
server_name ;

ssl_certificate /etc/letsencrypt/live//fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live//privkey.pem;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_stapling on;
ssl_stapling_verify on;
add_header Strict-Transport-Security max-age=15768000;

root /srv/http//public_html;
access_log /srv/http//logs/access.log;
error_log /srv/http//logs/error.log;

index index.php;

location / {
try_files $uri $uri/ /index.php?$query_string;
}

sendfile off;

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.0-fpm-.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}

location ~ /\.ht {
deny all;
}
}

sudo nginx -t
sudo service nginx restart

Securing Mautic

It’s always best to give the most limited permissions possible to website files. That said, there are some files that need more permissions than others, so we will loosen security where needed.

sudo chown -R $(whoami):www-data /srv/http//
sudo chown -R $(whoami): /srv/http//public_html/app/logs/
sudo chown -R $(whoami): /srv/http//public_html/app/cache/
sudo chown -R $(whoami): /srv/http//public_html/app/config/
sudo chown -R $(whoami): /srv/http//public_html/media/files/
sudo chown -R $(whoami): /srv/http//public_html/media/images/
sudo chown -R $(whoami): /srv/http//public_html/media/dashboards/
sudo chown -R $(whoami): /srv/http//public_html/translations/

sudo chmod -R g+w /srv/http//logs/
sudo chmod -R g+w /srv/http//public_html/app/logs/
sudo chmod -R g+w /srv/http//public_html/app/cache
sudo chmod -R g+w /srv/http//public_html/app/config/
sudo chmod -R g+w /srv/http//public_html/media/files/
sudo chmod -R g+w /srv/http//public_html/media/images/
sudo chmod -R g+w /srv/http//public_html/media/dashboards/
sudo chmod -R g+w /srv/http//public_html/translations/

Setup Email

One of the key tasks of Mautic is sending out emails. To facilitate this we need a mail transport agent…we’ll use sendmail. Simply install it and PHP should be able to use it.

sudo apt-get install -y sendmail

Add Cron Jobs

There are several tasks that need to be run in the background periodically to keep Mautic ticking along. Cron jobs can be created to automate these tasks…the following commands will run these tasks every five minutes as the user we created for Mautic. I have the last one commented out since it is only needed if you will be queuing your outgoing emails.

sudo su -c "crontab -e" site_mautic

*/5 * * * * php /srv/http//public_html/app/console mautic:segments:update
*/5 * * * * php /srv/http//public_html/app/console mautic:campaigns:rebuild
*/5 * * * * php /srv/http//public_html/app/console mautic:campaigns:trigger
#*/5 * * * * php /srv/http//public_html/app/console mautic:emails:send

Configure Mautic

You should now have a complete install. Next you need to configure your new marketing automation platform and connect it to your website. I plan to do more guides on actually using your new marketing automation platform, but there is a Getting Started guide that can take you from here. Thoughts or questions are always welcome.

Leave a Reply

Your email address will not be published. Required fields are marked *