There was a problem loading the comments.

Install Mautic Marketing Automation on Ubuntu 20.04

Support Portal  »  Tutorials  »  Viewing Article

  Print
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 Automation 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.

Setup Requirements

We need to meet the following requirements to successfully get Mautic installed.
  • PHP >=7.2.21 <7.4
  • 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 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. Check out How To Install MariaDB 10.5 on Ubuntu
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.

MariaDB [(none)]> CREATE DATABASE mautic_database;
MariaDB [(none)]> CREATE USER 'usermautic'@'localhost' IDENTIFIED BY 'StrongPassword';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON mautic_database . * TO 'usermautic'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit;

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 <7.4. PHP version (7.4.3) will not satisfy that requirement. Therefore, we shall use PHP Version 7.3.
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.3

sudo apt install php7.3-{cli,fpm,json,common,mysql,zip,gd,mbstring,curl,xml,pear,bcmath,imap,intl}

Check if php-fpm is running.

$ systemctl status php7.3-fpm
● php7.3-fpm.service - The PHP 7.3 FastCGI Process Manager
     Loaded: loaded (/lib/systemd/system/php7.3-fpm.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2020-07-13 13:27:53 EAT; 2min 12s ago
       Docs: man:php-fpm7.3(8)
    Process: 97804 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/7.3/fpm/pool.d/www.conf 73 (code=exi>   Main PID: 97791 (php-fpm7.3)
     Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
      Tasks: 3 (limit: 1035)
     Memory: 10.7M
     CGroup: /system.slice/php7.3-fpm.service
             ├─97791 php-fpm: master process (/etc/php/7.3/fpm/php-fpm.conf)
             ├─97802 php-fpm: pool www
             └─97803 php-fpm: pool www

Jul 13 13:27:52 ubuntu-20 systemd[1]: Starting The PHP 7.3 FastCGI Process Manager...
Jul 13 13:27:53 ubuntu-20 systemd[1]: Started The PHP 7.3 FastCGI Process Manager.

Add Mautic’s recommended PHP Settings

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 nano /etc/php/7.3/fpm/php.ini

memory_limit = 512M

[Date]

date.timezone = Asia/Dubai

Configure 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.

cd /etc/nginx/sites-enabled/
sudo mv default /tmp

Create a new file and add the details shown below. If you have an FQDN, replace example.com with it.

$ 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.3-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;
}

Step 4: Clone Mautic files from git and install composer

The root directory is the folder our Webserver will check out for Mautic files and serve them upon request. From the Nginx configuration we have done above, you can confirm that the root directory is /var/www/html/mautic. You can create a different one according to your needs.

cd /var/www/html/
sudo git clone <a href="https://github.com/mautic/mautic.git">https://github.com/mautic/mautic.git</a>

A new directory inside /var/www/html/ called mautic will be created and files copied into it. This (/var/www/html/mautic) will be our root directory.

Install composer

Composer is required to in order to get Mautic’s dependencies installed. Do the following to setup composer

cd ~
curl -sS <a href="https://getcomposer.org/installer">https://getcomposer.org/installer</a> -o composer-setup.php
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

Test if composer is successfully installed by running the composer version command

$ composer -V
Composer version 1.10.8 2020-06-24 21:23:30

After composer is installed, change into the root directory as above and run composer install to have our dependencies installed.

cd /var/www/html/mautic
sudo composer install  ## This might take some time to complete!

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.3-fpm

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

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
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.
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.
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.
Next, you will be required to log into Mautic Dashboard using the Administrative User details.
And your dashboard should blaze your eyes and beckon you to start configuring contacts, campaigns, Channels and others.

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

We now have this Marketing software platform ready for use and we hope the guide was helpful.

Share via
Did you find this article useful?  

Related Articles

© Bamboozle Web Services Inc.