How to Install Mautic Marketing Automation Tool on CentOS 7

Mautic is an open source and self-hosted marketing automation tool for everyone. It allows you to grow up your business, monitor your website, create landing pages, create campaigns for your business, manage contacts, and send marketing emails.

In this tutorial, I will show you step-by-step how to install Mautic Marketing Automation Platform on CentOS 7. It’s a web-based application, and we will be using the LEMP (Linux, Nginx, MySQL/MariaDB, PHP) stack for our installation guide.

Prerequisites

  • CentOS 7 server
  • Root privileges

What we will do

  1. Install EPEL Repository
  2. Install Nginx Webserver
  3. Install and Configure MariaDB
  4. Install and Configure PHP-FPM
  5. Download Mautic
  6. Configure Nginx Virtual Host for Mautic
  7. Mautic Web-based Installation

Step 1 – Install EPEL Repository

The first thing we must do is to add new EPEL repository to the system.

Add new EPEL repository to the CentOS 7 system using the following command.

yum -y install epel-release

New EPEL repository has been installed and added to the system.

Step 2 – Install Nginx

Install the Nginx web server from the EPEL repository using the following yum command.

yum -y install nginx

After the installation is complete, start the service and enable it to launch at system boot.

systemctl start nginx
systemctl enable nginx

Now check it using the netstat command.

netstat -plntu

And make sure you get the result as shown below.

Check if nginx is working with the netstat command

Step 3 – Install and Configure MariaDB

Mautic offers support only for the MySQL database with min version 5.5.3. For this guide, we will be using the mariadb-server 10.0 based on MySQL 5.5.

Install the mariadb database using the yum command below.

yum -y install mariadb-server

After the installation is complete, start the mariadb service and enable it to launch at boot time.

systemctl start mariadb
systemctl enable mariadb

For security reasons, we need to configure the mysql root password.

Run the ‘mysql_secure_installation’ command as shown below.

mysql_secure_installation

And you will be asked about some mysql configuration – see below.

Set root password? [Y/n] Y
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

The MariaDB installation has been completed.

Next, we need to add new database and user for the Mautic installation. We will create a new database named ‘mautic’ with user ‘mauticuser’ and password ‘aqwe123’.

Login to the mysql server using the myql command.

mysql -u root -p

Now create new database and user using the mysql queries below.

create database mautic;
grant all on mautic.* to ‘mauticuser’@’localhost’ IDENTIFIED BY ‘aqwe123’;
flush privileges;
exit;

Create mautic database

The MySQL database and user for mautic installation has been created.

Step 4 – Install and Configure PHP-FPM

Mautic requires PHP 5.6.19 (at-least) for installation. And for this guide, we will be using PHP-FPM 7.0 from the ‘webtatic’ repository.

Add new ‘webtatic’ repository for PHP 7.

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

Now install PHP and PHP-FPM with all required extensions using the following yum command.

yum -y install php70w-fpm php70w-mbstring php70w-xml php70w-mysql php70w-common php70w-gd php70w-json php70w-cli php70w-curl php70w-zip php70w-xml php70w-mcrypt php70w-imap php70w-intl php70w-process

PHP and PHP-FPM with all required extensions have been installed. Next, we need to configure PHP and PHP-FPM.

For this, we need to edit the ‘php.ini’ file and edit the php-fpm pool configuration file ‘www.conf’.

Edit the ‘php.ini’ file using vim editor.

vim /etc/php.ini

Uncomment the ‘date.timezone’ line and set the default time zone to ‘UTC’.

date.timezone = "UTC"

Uncomment the ‘cgi.fix_pathinfo’ line and change the value to ‘0’.

cgi.fix_pathinfo = 0

For the PHP session path configuration, uncomment the ‘session.save_path’ line and change it to the ‘/var/lib/php/session’ directory as below.

session.save_path = "/var/lib/php/session"

Save these changes and exit the editor.

Now, edit the PHP-FPM pool configuration file ‘www.conf’ using vim.

vim /etc/php-fpm.d/www.conf

Change the default user and group for PHP-FPM to the ‘nginx’ user.

user = nginx
group = nginx

Instead of using the system port, PHP-FPM will be running under the sock file. Change the ‘listen’ line as shown below.

listen = /var/run/php-fpm/php-fpm.sock

Now set the owner of the sock file to the ‘nginx’ user with permission ‘660’.

listen.owner = nginx
listen.group = nginx
listen.mode = 0660

That’s it for this file. Save and exit.

Next, create a new directory for the PHP session file and change the owner to the ‘nginx’ user.

mkdir -p /var/lib/php/session/
chown -R nginx:nginx /var/lib/php/session/

Now start the php-fpm service and enable it to launch at system boot.

systemctl start php-fpm
systemctl enable php-fpm

PHP and PHP-FPM have been installed, and the latter is running under the sock file.

Check it using the netstat command below.

netstat -pl | grep php-fpm.sock

And you should get the result as below.

Configure PHP

Step 5 – Download Mautic

Create a new directory ‘/var/www’ and enter it.

mkdir -p /var/www
cd /var/www/

Now download the mautic source code using wget, then extract it to the ‘mautic’ directory using the unzip command.

wget https://www.mautic.org/download/latest
unzip latest -d mautic/

Note: If you get a result saying ‘unzip command not found’, install the package using the following yum command.

yum -y install unzip

Now change the ownership for ‘mautic’ directory to the ‘nginx’ user and group.

sudo chown -R nginx:nginx mautic/

Mautic source code has been downloaded, and the ‘/var/www/mautic’ directory will be the webroot directory for mautic.

Step 6 – Configure Nginx Virtual Host for Mautic

For this guide, we’re using Nginx instead of Apache web server. In this step, we will configure the Nginx virtual host for our mautic installation on the CentOS 7 system.

Goto the ‘/etc/nginx’ directory and create a new file named ‘mautic.conf’ under the ‘conf.d’ directory using the vim editor.

cd /etc/nginx/
vim conf.d/mautic.conf

Paste the following Nginx virtual host configuration there.

server {
    listen 80;
    listen [::]:80;
    server_name mautic.hakase-labs.co;

    root /var/www/mautic;
    index index.php index.html index.htm index.nginx-debian.html;

    location / {
      try_files $uri $uri/ =404;
    }

    location ~ .php$ {
      include fastcgi.conf;
      fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
    }

    location ~* ^/index.php {
      fastcgi_split_path_info ^(.+.php)(/.+)$;
      fastcgi_pass unix:/var/run/php-fpm/php-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;
    }
}

That’s it. Save and exit.

Now test the nginx configuration and make sure there is no error. Then restart the nginx service.

nginx -t
systemctl restart nginx

Nginx virtual host configuration for mautic has been completed.

Configure Nginx, test and apply the config

Step 7 – Mautic Web-based installation

Open your web browser and visit the mautic domain name, mine is: http://mautic.hakase-labs.co

You will be redirected to the mautic installation page. There, make sure all the extensions and configuration has no error.

Mautic web installer

Click the ‘Next Step‘ button to continue.

Now you will see the page about the database configuration.

Type your database name, database user, and password as below.

Set the database details for Mautic

And click the ‘Next Step‘ button.

Next, we need to create a new admin account for Mautic.

Type your admin user, email, and password.

Add a admin user

Click ‘Next Step‘ button.

Next up is the email configuration – you can choose one option, or you can do this configuration later.

Email configuration

Click the ‘Next Step‘ button again.

Now, you will get the admin login page.

Type your admin user and password and click the ‘Login’ button.

Login to Mautic

You’ll be taken to the Mautic admin dashboard as shown below.

Mautic Marketing Automation Tool

The Mautic marketing automation tool installation on CentOS 7 with Nginx web server has been completed successfully.

Reference

Share this page:

نوشته های مشابه