Build And Configure Mautic 3 Email Marketing System

BY: Services GroundOn December 15, 2020
Build And Configure Mautic 3 Email Marketing System

Mautic

How To Build And Configure Mautic 3, Mautic is an open-source, marketing automation system and is widely used as an automated email marketing solution.

What do we mean by automated email marketing?

If you have a little bit of experience in email marketing then you’ll be familiar with the email marketing plans consist of two parts:

The Sender: this is the technical part of the SMTP server. You can send emails with the permission of this server online. 

An Administration software: where you can configure and manage your email list, advertising campaigns, monitor and analyze results, manage your sending servers, and so on. So, we can connect both to get an email marketing plan. 

In this article, I’ll show you how to build Mautic and here the administration is Mautic

email marketing system

Get Ready To Install Mautic

The requirement to build Mautic 

To build Mautic we should have two things:

  • A VPS Server to install Mautic on.
  • Domain Name for your setup use.

First Get A VPS Server 

You are required to get a VPS server first to install Mautic on. You can get a VPS server from the company of your own choice. Moving on, we’ll use Contabo services in this guide. 

After you get the VPS server just create a server with the following specifications:

  • Ubuntu 16/18 x64 as your operating system.
  • 1 CPU/ 1 GB RAM is enough for starting and you can upgrade later.  

Get a Domain Name

If you don’t have a domain then getting a domain is just a piece of cake. All you just need to go to any of the domain registration company and buy a domain name. Here are the names of some company from where you can get your domain register:

GodaddyEnom

Freenom

Namecheap

Point Domain to VPS.

Before proceeding, you’ve to point your domain or subdomain to your IP address. But here I’ll point subdomain “mautic.example.me” to my Contabo IP address. OK now we have a domain and VPS server, let’s start the installation process. 

You can use an SSH client like putty to connect to your server and also Install Apache, PHP, and MySQL which are the pre requests for hosting any PHP application like mautic.

Install Apache2 Web Server

Install Apache Web Server on your VPS by running the following command:

sudo apt update
sudo apt install apache2

After the installation complete, enable the service by running the following command.

sudo systemctl restart apache2.service
sudo systemctl enable apache2.service

Then inspect the working of Apache on your server by browsing the VPS IP address (http://Your_IP_Address).

The default page should be like this:

apache default page

Install MariaDB (MySQL) Database Server

Mautic also requires a Database to save data because it’s working is not much different from PHP System.

To install MariaDB run the commands below (Choose between Ubuntu 16,18):

Run these on Ubuntu 16 LTS:

sudo apt-get install software-properties-common gnupg-curl
sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo add-apt-repository 'deb [arch=amd64,arm64,i386,ppc64el] http://mirrors.piconets.webwerks.in/mariadb-mirror/repo/10.5/ubuntu xenial main'
sudo apt update
sudo apt-get install mariadb-server

Run these on Ubuntu 18 LTS:

sudo apt-get install software-properties-common
sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://mirrors.piconets.webwerks.in/mariadb-mirror/repo/10.5/ubuntu bionic main'
sudo apt update
sudo apt-get install mariadb-server

You can stop MariaDB by running the following command.

Run these on Ubuntu 16 LTS

sudo systemctl stop mysql.service
sudo systemctl start mysql.service
sudo systemctl enable mysql.service

Run these on Ubuntu 18 LTS

sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

After that, create a root password and disallow the remote root to secure your MariaDB by running the following command.

sudo mysql_secure_installation

When prompted, enter these answers:

  1. For Socket password enter N
  2. In current password input just press Enter
  3. For set a root password [Y/n] enter: Y
  4. Create a secure new password if you’re asked to enter a new password
  5. Re-enter new password
  6. Remove anonymous users? [Y/n]: Y
  7. Disallow root login remotely? [Y/n]: Y
  8. Remove test database and access to it? [Y/n]:  Y
  9. Reload privilege tables now? [Y/n]:  Y

Restart MariaDB Mysql Service

To test if MariaDB is installed, type the command below to logon to MariaDB server

sudo mysql -u root -p

Then login by typing the password you created above. If it works you’ll receive the welcome message like this:

MariaDB Mysql Service
  • Install PHP And Related Modules

Mautic is a PHP based script so, we have to install some modules and PHP on the server. In this guide, we’ll install PHP 7.4 but you can use any version you want. Just change “7.4” to 7.X” in the commands.

Add the repository of the third party to install PHP 7.4 by running the following command.

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php

After that update this:

sudo apt update

Then install PHP 7.4 and related modules. By running the following commands

sudo apt install php7.4 libapache2-mod-php7.4 php7.4-common php7.4-gmp php7.4-curl php7.4-intl php7.4-mbstring php7.4-xmlrpc php7.4-mysql php7.4-bcmath php7.4-gd php7.4-xml php7.4-cli php7.4-zip php7.4-imap

Run the following command:

sudo apt install php-pcov

Now you’ve installed PHP, Open WinSCP to edit the php.ini file. WinSCP works over SSH so, it will make things a lot easier with putty.

Apply changes by following these guidelines:

  • Open WinSCP and use your server IP/Name and root credentials to connect to your server.
  • Then go to “/etc/php/7.X/apache2/” where you can find the “php.ini” configuration file.
how to install PHP
  • Right-click on “php.ini” and Click Edit.
  • Then, make some changes in the following lines below in the file and save. 
file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 256M //You can increase this if you server can handle
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = America/NewYork //Set your Time Zone here
  • After applying these changes, save and close the files.
  • Then restart apache service again
sudo systemctl restart apache2.service
  • Create Mautic Database

Now our server is ready to install so, we need to create a Database for Mautic in MariaDB.

To login, MariaDB MySql database server we’ve to run the following commands.

sudo mysql -u root -p

Then create a database called mautic (or any name you want)

CREATE DATABASE mautic;

Create a database user called mautic with a new password

CREATE USER 'mautic'@'localhost' IDENTIFIED BY 'Enter_Your_Password_Here'

Then grant the user full access to the database.

GRANT ALL ON mautic.* TO 'mautic'@'localhost' IDENTIFIED BY 'Enter_your_password_here' WITH GRANT OPTION;

Finally, save your changes and exit.

FLUSH PRIVILEGES;
EXIT
  • Download And Install Mautic

To get the latest version of Mautic you can use Github repository. So, install composer, Curl and other dependencies.

Run these commands for installation.

#First Command:
sudo apt install curl git

#Second Command:
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer --version=1.10.13

When the operation finishes, replace the directory with “/var/www/html” by running the following command:

cd /var/www/html

Then Download Mautic package:

sudo git clone https://github.com/mautic/mautic.git

Now Install Mautic by running the following commands:

cd /var/www/html/mautic

sudo composer instal

After the installation finishes, get the permission to set some files by running the following commands.

sudo chown -R www-data:www-data /var/www/html/mautic/

sudo chmod -R 755 /var/www/html/mautic/

Configure Apache2 Web Server

Now we’ve installed the Mautic. So, you’ve to configure Apache to access the Mautic by using your domain name. How To Build And Configure Mautic 3.

In order to do so first follow the below steps:

  • Open WinSCP again and navigate to this directory: /etc/apache2/sites-available/.
  • Then, create a new file and name it “mautic.example.com.conf” to change your domain.
  • Create mautic.conf
how to configure apache2 server
  • Open mautic.conf 
  • Copy and paste the content below into the file and save.
<VirtualHost *:80>
     ServerAdmin admin@mautic.example.com
     DocumentRoot /var/www/html/mautic
     ServerName mautic.example.com
     ServerAlias mautic.example.com

     <Directory /var/www/html/mautic/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>
  • Replace this domain with your own domain. Here it is mautic.example
  • .com”
  • Enable mautic configuration in apache and restart the service.

Now finish the setup by running the following Setup to How To Build And Configure Mautic 3.

sudo a2ensite mautic.example.com.conf

sudo a2enmod rewrite

sudo systemctl restart apache2.service

Now go to the Web browser and navigate to your server name like this:

//mautic.example.com

You must see the setup completion wizard below:

mautic installation

Enter the database and your admin login information to continue the setup process.

  • Configure Cron Jobs

Now we’ve installed the Mautic, we just need to setup the Cron jobs.

What are Cron Jobs?

Simply Cron Jobs is an organized activity that works automatically on a schedule.

For example, if you create an automated email campaign that run every week. You need a function that will automatically runs in the background to boost this campaign, this is the Cron job role, so do the setup.

Mautic needs many Cron functions, some are required and some are optional, check out the list of all Cron jobs here in mautic. All you just have to copy the jobs below and paste them on your server to put them into action.

#Segments Every 2 Minutes
*/2 * * * * root /usr/bin/php /var/www/html/mautic/bin/console mautic:segments:update
*/3 * * * * root /usr/bin/php /var/www/html/mautic/bin/console mautic:import

#Campaigns (Every 1 Minute)
* * * * * root /usr/bin/php /var/www/html/mautic/bin/console mautic:campaigns:update
* * * * * root /usr/bin/php /var/www/html/mautic/bin/console
mautic:campaigns:trigger
* * * * * root /usr/bin/php /var/www/html/mautic/bin/console mautic:messages:send

#Process Email Queue Every 5 Minutes
*/5 * * * * root /usr/bin/php /var/www/html/mautic/bin/console mautic:emails:send
#Fetch and Process Monitored Email Every 10 Minutes
*/10 * * * * root /usr/bin/php /var/www/html/mautic/bin/console mautic:email:fetch


#Process Email Queue Every 5 Minutes
*/5 * * * * root /usr/bin/php /var/www/html/mautic/bin/console mautic:emails:send

#Fetch and Process Monitored Email Every 10 Minutes
*/10 * * * * root /usr/bin/php /var/www/html/mautic/bin/console mautic:email:fetch

Where to paste them?

  • Paste the jobs on your server by following these steps:
  • Open WinSCP
  • Go to“/etc” directory click on the “crontab” file
what are cron jobs
  • Click it and you’ll get the edit option
  • Then paste the desire functions in it and save it.
cron job
  • After that click on exist, the process is done here!

Optional: Secure with a Free SSL

SSL certificates are used to encrypt the traffic between the server and client, providing additional security for users accessing your application. Let’s Encrypt provides an easy way to install trusted certificates for free.

Connect to your server using the Putty SSH client.

Install Let’s Encrypt Client

You can get the Let’s Encrypt Certificate through client software running on your server.

First, add the repository to install Cerbot (official client):

sudo add-apt-repository ppa:certbot/certbot

You’ll need to press ENTER to accept.

Then, to get the new package info just update the list.

sudo apt-get update

Install Certbot’s Apache package:

sudo apt install python-certbot-apache

Certbot is now ready to be used.

  •  

Build SSL Certificate

Cerbot is quite easy to generate the SSL certificate for Apache. A new SSL certificate will be provided automatically to the client that is valid for the domains which are provided in the form of parameters.

Simply run the following command to change the domain:

sudo certbot --apache -d mautic.example.com

Then you’ve to provide an email address for lost key recovery and notices to get the authority to choose between enabling both http and https access or forcing all requests to redirect to https. If you don’t have a specific need for unencrypted traffic then it will be safest to require.

Test your website now. Here I’ll test my website by browsing this “https://mautic.example.com” This is the guide about How To Build And Configure Mautic 3.

Good Luck!
If you liked this article and want to read more of these, please subscribe to our newsletter and follow us on FacebookYouTube, and Twitter.