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.
- CentOS 7 server
- Root privileges
What we will do
- Install EPEL Repository
- Install Nginx Webserver
- Install and Configure MariaDB
- Install and Configure PHP-FPM
- Download Mautic
- Configure Nginx Virtual Host for Mautic
- 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.
And make sure you get the result as shown below.
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.
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’;
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.
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.
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.
Step 5 – Download Mautic
Create a new directory ‘/var/www’ and enter it.
mkdir -p /var/www
Now download the mautic source code using wget, then extract it to the ‘mautic’ directory using the unzip command.
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.
Paste the following Nginx virtual host configuration there.
index index.php index.html index.htm index.nginx-debian.html;
try_files $uri $uri/ =404;
location ~ .php$
location ~* ^/index.php
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_buffers 256 16k;
That’s it. Save and exit.
Now test the nginx configuration and make sure there is no error. Then restart the nginx service.
systemctl restart nginx
Nginx virtual host configuration for mautic has been completed.
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.
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.
And click the ‘Next Step‘ button.
Next, we need to create a new admin account for Mautic.
Type your admin user, email, and password.
Click ‘Next Step‘ button.
Next up is the email configuration – you can choose one option, or you can do this configuration later.
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.
You’ll be taken to the Mautic admin dashboard as shown below.
The Mautic marketing automation tool installation on CentOS 7 with Nginx web server has been completed successfully.