Home / How To / How to install Mautic Marketing Automation Tool on Ubuntu 20.04

How to install Mautic Marketing Automation Tool on Ubuntu 20.04



Mautic is an open source tool for automating marketing for everyone. You can use it to grow your business or community, monitor your website, create landing pages, create a campaign for your business, manage contacts and even send marketing emails.

This tutorial shows you how to install the Mautic Marketing Automation Tool on the latest Ubuntu 20.04 server. We install Mautic with LEMP Stack (Linux, Nginx, MySQL and PHP-FPM), and we will secure our installation with SSL Letsencrypt.

Conditions

  • Ubuntu 20.04 server
  • 2 GB or more RAM
  • Root privileges

What should we do?

  • Install Nginx Web Server
  • Install and configure PHP-FPM 7.3 on Ubuntu 20.04
  • Install and configure MySQL Server
  • Create SSL Letsencrypt
  • Download Mautic source code Latest version
  • Configure Nginx server blocks for Mautic
  • Mautic Post Installation

Step 1 – Install Nginx Web Server

First, we install the Nginx packages for the Ubuntu 20.04 server. Mautic software runs under the Nginx web server with a secure HTTPS connection.

Update all available archives on your system and install Nginx packages using the apt command below.

sudo apt update
sudo apt install nginx -y

When all installation is complete, start the Nginx service and add it to system boot.

systemctl start nginx
systemctl enable nginx

The Nginx service is running, check with the following command.

systemctl status nginx

Below is the result you get.

Install Nginx on Ubuntu 20.04

As a result, the installation of the Nginx web server on Ubuntu Server has been completed.

Step 2 – Install and configure PHP-FPM 7.3 on Ubuntu 20.04

At present, Mautic software still does not support the new PHP 7.4 version. In that case, we install the PHP 7.3 packages from the PPA repository to our Ubuntu 20.04 server.

Install the ‘software-properties-common’ package and add the PPP repository for PHP with the command below.

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

When all is done, you are ready to install and configure PHP-FPM 7.3 packages.

Add PHP 7.3 Repository to Ubuntu 20.04

Install the PHP-FPM 7.3 package with some additional packages using the apt command below.

sudo apt install -y php7.3-fpm php7.3-mbstring php7.3-xml php7.3-mysql php7.3-common php7.3-gd php7.3-json php7.3-cli php7.3-curl php7.3-zip php7.3-xml php7.3-imap php7.3-intl

When all installation is complete, go to the directory ‘/etc/php/7.3/fpm’ and edit the configuration file ‘php.ini’ with vim-editor.

cd /etc/php/7.3/fpm/
vim php.ini

Deselect the following lines and change the values ​​as below.

date.timezone = "UTC"
cgi.fix_pathinfo = 0

Save and close.

Then start the PHP-FPM service and add it to the startup time.

systemctl start php7.3-fpm
systemctl enable php7.3-fpm

Start the PHP-FPM service

The PHP-FPM service is running. Check with the following command.

systemctl status php7.3-fpm
ss -pl | grep php

Below is the result you get.

Check the PHP-FPM service status

As shown, the PHP-FPM service is running under the sock file ‘/var/run/php/php7.3-fpm.sock’.Advertisement

Advertisement

As a result, the installation and configuration of PHP-FPM 7.3 on Ubuntu 20.04 Server has been completed.

Step 3 – Install and configure MySQL Server

In this step, we will install the MySQL server and configure the default MySQL root password using the ‘mysql_secure_installation’ command function. And after that we create a new MySQL database and users for our Mautic installation.

Install MySQL Server package using the apt command below.

sudo apt install mysql-server mysql-client

When all installation is complete, start the MySQL service and add it to system boot.

systemctl start mysql
systemctl enable mysql

Now check the status of the MySQL service with the following command.

systemctl status mysql

Below is the result you get.

Install MySQL Server on Ubuntu 20.04

As can be seen, the MySQL service is running on the Ubuntu 20.04 server.

Next, we will set the MySQL root password using the “mysql_secure_installation” command provided by MySQL.

Run the command ‘mysql_secure_installation’ below.Advertisement

mysql_secure_installation

Now you will be prompted for some configurations, enter your new MySQL root user password and type ‘AND‘for other configuration.

Press y|Y for Yes, any other key for No: 
Please set the password for root here.

New password:
Re-enter new password:

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y

As a result, the password configuration for the MySQL root user has been completed and was ready to create a new database and users for Mautic.

Then log in to the MySQL shell using the ‘mysql’ command below.

mysql -u root -p

Create a new database named ‘mautic_db‘and the user’mauticuser‘with the password’mautic321‘with the following questions.

CREATE DATABASE mautic_db;
CREATE USER [email protected] IDENTIFIED WITH mysql_native_password BY 'mautic321';
GRANT ALL PRIVILEGES ON mautic_db.* TO [email protected] WITH GRANT OPTION;
FLUSH PRIVILEGES;

Write now ‘output‘to log out of the MySQL shell.

Create database and users for Mautic

As a result, the MySQL database and the Mautic installation user have been created.

Step 4 – Create SSL Letsencrypt

For this tutorial we will secure our Mautic installation with SSL Letsencrypt. Also make sure you have a domain name and it is resolved to your server’s IP address.

Now install the certbot tool to generate SSL Letsencrypt using the apt command below.

sudo apt install certbot

When all the installation is complete, stop the Nginx service and create SSL Letsencrypt using the command below. Also make sure to change the email address and with your own.

systemctl stop nginx
certbot certonly --rsa-key-size 2048 --standalone --agree-tos --no-eff-email --email [email protected] -d mautic.hakase-labs.io

Everything is ready, your SSL certificates will be available in the directory ‘/etc/letsencrypt/live/your-domain.com/’.

As a result, SSL Letsencrypt certificates for Mautic have been generated.

Step 5 – Download the latest version of the Mautic source code

In this step, we download and install the latest Matic version in the directory ‘/ var / www’.

Before downloading the Mautic source code, install the package for the package using the apt command below.

sudo apt install unzip

Then go to the directory ‘/ var / www’ and download the Mautic source code using the wget command below.

cd /var/www/
wget -q https://www.mautic.org/download/latest

Extract the Mautic source code to the new directory named ‘mautic’ and then change the ownership of the ‘mautic’ directory to the ‘www-data’ user.

unzip -qq latest -d mautic
sudo chown -R www-data:www-data /var/www/mautic

As a result, the Mautic source code has been downloaded to the directory ‘/ var / www’, and we are ready to install the software tool Mautic Marketing.

Download Mautic source code

Step 6 – Set up Nginx server blocks for Mautic

In this step, we set up the Nginx server blocks for the Mautic installation.

Now go to the directory ‘/ etc / nginx / sites-available’ and create a new configuration ‘mautic’ with vim-editor.

cd /etc/nginx/sites-available/
vim mautic

Change the domain name and path of the SSL certificates with your own, and then paste the configuration into it.

server {
    listen               80;
    server_name          mautic.hakase-labs.io;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl;
    server_name mautic.hakase-labs.io;

    ssl_certificate /etc/letsencrypt/live/mautic.hakase-labs.io/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mautic.hakase-labs.io/privkey.pem;
    
    ssl_session_timeout 5m;
    ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";

    client_max_body_size 4M;
    client_body_buffer_size 128k;
      
     root /var/www/mautic;
     index index.php index.html index.htm index.nginx-debian.html;
      
     location / {
       try_files $uri $uri/ =404;
     }
 
     location ~ .php$ {
       include snippets/fastcgi-php.conf;
       fastcgi_pass unix:/run/php/php7.3-fpm.sock;
     }
 
     location ~* ^/index.php {
       fastcgi_split_path_info ^(.+.php)(/.+)$;
       fastcgi_pass unix:/var/run/php/php7.3-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;
     }
}

Save and close.Advertisement

Then enable Nginx virtual blocks for Mautic and perform a configuration test. Also make sure there is nothing wrong.

ln -s /etc/nginx/sites-available/mautic /etc/nginx/sites-enabled/
nginx -t

Restart the Nginx service to apply the new server block configuration.

systemctl restart nginx

As a result, the Nginx server has blocked the configuration of Mautic and we are ready to continue with Mautic Post Installation.

Set up Nginx server blocks for Mautic

Step 7 – Installation of Mautic Post

Open your browser and enter the domain name of your Mautic installation in the address bar. Mine is:

https://mautic.hakase-labs.io/

The Mautic installer performs system environment checks for the installation and ensures that you get “Ready to install“message as below.

Mautic Check the environment for the installation

Click ‘Next stepto continue the installation.

Now enter information MySQL database for the Mautic installation and click on ‘Next step‘ continue.

Mautic Database Configuration

Then enter the new administrator user, Mautic email address and password and click ‘Next step‘ button.

Mautic Create administrator users and passwords

For the Mautic Email configuration, select as needed and click ‘Next step‘ button.

Mautic Setup Email Marketing Provider

And the Mautic installation is complete and you will be redirected to the Mautic login page.

Mautic login page

Enter your administrator user and password, then click ‘Sign in‘ button.

Now you get the Mautic Dashboard.

Mautic Admin Dashboard

As a result, the installation of Mautic with the Nginx Web Server, MySQL Database, and PHP-FPM on Ubuntu 20.04 has been successfully completed.

Reference


Source link