Install Mautic Marketing Software on Ubuntu 20.04 | 18.04

Hostnbit

Running a fully-fledged business can be one of the most satisfying and yet equally challenging task one can ever venture into. Firstly, you have to have a general picture of how the different departments should work in harmony to come up with the dream and vision at the heart of it all.

Secondly, you have to ensure that your customers have the best experience you can afford to proffer when they are interacting with your product or service. Moreover, you need to reach as many customers as you can and maintain the relationships you have built with them over time. It is definitely not easy but the strong at heart always push the wheels of the challenges to win.

Fortunately, there are tools created by awesome people that make running businesses better and more engaging. One such tool is Mautic Marketing Software which is Open Source and amazing. This guide focuses on how to get this software running in your organization to help you handle marketing and your precious customers in a superior manner.

In a nutshell, Mautic is an Open Marketing software platform that provides you with the greatest level of integration and deep audience intelligence, enabling you to make more meaningful customer connections throughout the relationship lifecycles. Now into the crux of the guide, we shall get Mautic installed in Ubuntu 20.04 or Ubuntu 18.04.

Setup Requirements

We need to meet the following requirements to successfully get Mautic installed.

  • PHP >=7.2.21
  • PHP modules:
  • Required: zip, xml, mcrypt, imap, mailparse
  • Nginx | Apache web server
  • MySQL Database server
  • Git
  • Composer

Step 1: Update and install essential tools

Once in the terminal of your fresh Ubuntu server, update it and install essential tools we shall use in our installation process

sudo apt update && sudo apt upgrade
sudo apt install vim git unzip curl -y

Step 2: Install and setup database

We are going to use MariaDB for this setup. Fortunately, we have a detailed guide already to get MariaDB 10.5 installed. 

To install the default version in your OS repositories run:

sudo apt update
sudo apt -y install mariadb-server

After you have the database installed, the next step is to create a database and user for Mautic. Let us, therefore, go ahead and get this done as shown below. You are free to name your database and user differently and ensure you use a safe password.

$ sudo mysql -u root

CREATE DATABASE mautic;
CREATE USER 'mautic'@'localhost' IDENTIFIED BY 'StrongPassword';
GRANT ALL PRIVILEGES ON mautic.* TO 'mautic'@'localhost';
FLUSH PRIVILEGES;
exit;

That was easy and awesome.

Step 3: Install and configure a webserver and PHP

In order to get Mautic pages served, there has to be a webserver. Here, you have the freedom of either picking Apache or Nginx. We shall use Nginx for this guide. Additionally, Mautic requires PHP and therefore we will have to set it up as well. Note that the version of PHP required is PHP >=7.2.21.

Install php-fpm and dependencies

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install -y php7.4
sudo apt install php7.4-{cli,fpm,json,common,mysql,zip,gd,mbstring,curl,xml,bcmath,imap,intl}

Check if php-fpm is running.

$ systemctl status php7.4-fpm
● php7.4-fpm.service - The PHP 7.4 FastCGI Process Manager
     Loaded: loaded (/lib/systemd/system/php7.4-fpm.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2020-12-22 22:16:02 UTC; 28s ago
       Docs: man:php-fpm7.4(8)
    Process: 84661 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/7.4/fpm/pool.d/www.conf 74 (code=exited, status=0/SUCC>
   Main PID: 84647 (php-fpm7.4)
     Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
      Tasks: 3 (limit: 1137)
     Memory: 10.9M
     CGroup: /system.slice/php7.4-fpm.service
             ├─84647 php-fpm: master process (/etc/php/7.4/fpm/php-fpm.conf)
             ├─84659 php-fpm: pool www
             └─84660 php-fpm: pool www

Open up your php-fpm ini file and add/edit the details shown below. They include Timezone, and memory limit settings. Add your date.timezone (at about line 955) and change memory_limit (at about line 400) to 512MB.

$ sudo vim /etc/php/7.4/fpm/php.ini
memory_limit = 512M

[Date]
date.timezone = Africa/Nairobi

Step 4: Download Mautic source files

Visit Mautic Downloads page and pull the latest release. For me I’ll download directly from github.

wget https://github.com/mautic/mautic/releases/download/3.2.1/3.2.1.zip

Install unzip package.

sudo apt install unzip

Extract downloaded file.

unzip 3.2.1.zip -d mautic 

Move the mautic folder to the /var/www/html directory.

sudo mv mautic/ /var/www/html/

Change Mautic’s files permissions

In order for Nginx to read the files, we have to grant it the rights and the right permissions. Issue the commands below to get that done.

sudo chown -R www-data:www-data /var/www/html/mautic/
sudo chmod -R 755 /var/www/html/mautic/
sudo systemctl restart nginx php7.4-fpm

As you can see, our root directory is /var/www/html/mautic where we have our cloned Mautic files.

Configure Nginx

Install nginx Web server

sudo apt install nginx

We have to make a few changes to the Nginx configuration defaults by adding the details we need for Mautic.

Change into sites-enabled, back up the default file, and create a new one having new configurations.

sudo mv /etc/nginx/sites-enabled/default /root/nginx-default.backup

Create a new file and add the details shown below. If you have an FQDN, replace example.com with it. It can also be a subdomain such as mautic.example.com.

$ sudo vim /etc/nginx/sites-enabled/mautic.conf
server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  example.com;
        root         /var/www/html/mautic;
        index index.html index.htm index.php;

        location / {
                try_files $uri /index.php$is_args$args;
        }

        location ~ \.php$ {
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        fastcgi_index index.php;
        fastcgi_read_timeout 240;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        }
    rewrite ^themes/.*/(layouts|pages|partials)/.*.htm /index.php break;
    rewrite ^bootstrap/.* /index.php break;
    rewrite ^config/.* /index.php break;
    rewrite ^vendor/.* /index.php break;
    rewrite ^storage/cms/.* /index.php break;
    rewrite ^storage/logs/.* /index.php break;
    rewrite ^storage/framework/.* /index.php break;
    rewrite ^storage/temp/protected/.* /index.php break;
    rewrite ^storage/app/uploads/protected/.* /index.php break;
}

Validate nginx configurarion:

$ sudo nginx  -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Restart nginx

sudo systemctl disable --now apache2
sudo systemctl restart nginx

Step 5: Finish Mautic’s Installation via Panel

After everything has gone well thus far, we should be at our final stages of installing Mautic Marketing software. In this step open [http://ip-address-or-domain-name/] to launch the Mautic installation panel on your browser. The first page will be as shown below. You can view the recommendations and apply them if you can. Otherwise, click “Next Step

mautin installation 01

On the second page, you will be presented with a form to fill in Database details. These are the ones we set up in Step 3. Input the username and database name you used as well as your password. Since we have no existing database, click on “No“. Hit “Next Step” to Verifying the details and create the database. This may take a few seconds.

mautin installation 02 database

Once it is done, a new Administrative User form will be presented. Once again, fill in your Admin details and email then click “Next Step” button.

mautin installation 03 administrative user

The next pane requires your mail settings. The drop-down “Mailer-transport” part has many platforms you can use to be receiving your mail from Mautic. Kindly use the one you prefer here and enter the details as required. Click “Next Step” once done. This will complete the installation.

mautin installation 04 email config

Next, you will be required to log into Mautic Dashboard using the Administrative User details.

mautin installation 05 login

And your dashboard should blaze your eyes and beckon you to start configuring contacts, campaigns, Channels and others.

mautic installation 06 dashboard

Step 6: Add Cron Jobs

Mautic requires a few cron jobs to handle some maintenance tasks such as updating contacts or campaigns, executing campaign actions, sending emails, and more. Mautic needs some mandatory cron jobs to run on a regular basis. You must manually add the required cron jobs to your server.

As a refresher, below is the cron job guide.

# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed

To add Mautic’s mandatory cron jobs, issue the crontab command with -e (edit) option and add the cron jobs with times set as you desire.

$ sudo crontab -e

*/10 * * * 1  php /var/www/html/mautic/app/console mautic:segments:update >> /var/log/cronmautic.log 2>&1   
*/20 * * * 3  php /var/www/html/mautic/app/console mautic:campaigns:update >> /var/log/cronmautic.log 2>&1   
*/30 * * * 5  php /var/www/html/mautic/app/console mautic:campaigns:trigger >> /var/log/cronmautic.log 2>&1 

After that is done, we should be ready to use Mautic Software. You can go ahead and create new contacts, segments, campaigns and much more. Please check out the Official Mautic documentation on how to go about them.

Conclusion

Hostnbit

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Menu Title
Scroll to Top