Install and Configure Mautic on Ubuntu 16.04

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month. Get a Cloud Server

Introduction

Mautic is free and open source marketing automation application that can be used to save time and increase sales. You can also integrate mautic with various email services like Gmail, Sendgrid and Mandrill.

In this tutorial we will learn how to install Mautic on Ubuntu 16.04 server.

Requirements

A server running Ubuntu-16.04.

A non-root user with sudo privileges setup on your server.

Update the System

First, you will need to update the system with latest version of Ubuntu. You can do this with the following command:

sudo apt-get update -y

sudo apt-get upgrade -y

Installing LEMP Stack

Before starting, you will need to install the Nginx web server, PHP and MariaDB as a prerequisite of Mautic. You can install this by running the following command:

sudo apt-get install nginx mariadb-server php7.0-fpm php7.0-mbstring php7.0-xml php7.0-mysql php7.0-common php7.0-gd php7.0-json php7.0-cli php7.0-curl

Output:

Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libaio1 libcgi-fast-perl libcgi-pm-perl libdbd-mysql-perl libdbi-perl libencode-locale-perl libfcgi-perl libgd3 libhtml-parser-perl (truncated...)

Once installation is complete, start Nginx server and enable it to start on boot:

sudo systemctl start nginx

sudo systemctl enable nginx

You can see the status of Nginx and MariaDB with the following command:

sudo systemctl status nginx

Output:

nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2016-11-13 23:42:09 IST; 2min 48s ago Main PID: 17443 (nginx) CGroup: /system.slice/nginx.service ├─17443 nginx: master process /usr/sbin/nginx -g daemon on; master_process on └─17444 nginx: worker process Nov 13 23:42:09 Node1 systemd[1]: Starting A high performance web server and a reverse proxy server... Nov 13 23:42:09 Node1 systemd[1]: Started A high performance web server and a reverse proxy server. Nov 13 23:44:21 Node1 systemd[1]: Started A high performance web server and a reverse proxy server.

sudo systemctl status mysql

Output:

● mysql.service - LSB: Start and stop the mysql database server daemon Loaded: loaded (/etc/init.d/mysql; bad; vendor preset: enabled) Active: active (running) since Sun 2016-11-13 23:42:05 IST; 3min 21s ago Docs: man:systemd-sysv-generator(8) CGroup: /system.slice/mysql.service ├─17081 /bin/bash /usr/bin/mysqld_safe ├─17082 logger -p daemon err -t /etc/init.d/mysql -i ├─17226 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --skip-log-error --pid-fi └─17227 logger -t mysqld -p daemon error

If MariaDB is not running, start it with the following command:

sudo systemctl start mysql

Then, enable MariaDB service to start at boot with the following command:

sudo systemctl enable mysql

Next, you will need to secure MariaDB because default MariaDb installation is not secured.

You can secure it by running the mysql_secure_installation script:

sudo mysql_secure_installation

Answer all the questions as shown below:

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. (truncated...)

Installing Mautic

First, you will need to download the latest version of Mautic from it's official website. Otherwise, you can download it with the following command:

wget https://www.mautic.org/download/latest

The downloaded file is a zip archive. You can extract it using unzip command:

sudo unzip latest -d /var/www/html/mautic

Next, set proper permission to mautic directory:

sudo chown -R www-data:www-data /var/www/html/mautic

Configuring MariaDB for Mautic

Next, you will need to create a database for Mautic.

First, log in to mysql shell with the following command:

mysql -u root -p

Next, create a database for Mautic with the following command:

MariaDB [(none)]> create database mautic; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> grant all on mautic.* to 'mauticuser'@'localhost' IDENTIFIED BY 'password'; Query OK, 0 rows affected (0.07 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.04 sec) MariaDB [(none)]> exit; Bye

Configure Nginx for Mautic

Next, you will need to create a virtual host file for Nginx.

You can do this by creating mautic.conf file inside /etc/nginx/conf.d directory:

sudo nano /etc/nginx/conf.d/mautic.conf

Add the following lines:

server { listen 80; listen [::]:80; server_name 192.168.15.100; root /var/www/html/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.0-fpm.sock; } location ~* ^/index.php { fastcgi_split_path_info ^(.+.php)(/.+)$; fastcgi_pass unix:/var/run/php/php7.0-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 the file and create prod directory:

sudo mkdir /var/www/html/mautic/app/cache/prod

The, check the nginx configuration and restart nginx service:

sudo nginx -t

sudo systemctl reload nginx

Accessing the Mautic Web Interface

Next, it's time to access Mautic web installation wizard. Open your favourite web browser and tipe the URL http://your-server-ip, you should see the Mautic installation wizard as below:

HP_NO_IMG/data/uploads/users/7ecb43a5-b365-4ebf-93d5-f3b632f29f33/1395640663.png" alt="" />

Next, click on Next button and provide the MariaDB database details as follows:

HP_NO_IMG/data/uploads/users/7ecb43a5-b365-4ebf-93d5-f3b632f29f33/1640594582.png" alt="" />

Next, create an admin user for your Mautic installation:

HP_NO_IMG/data/uploads/users/7ecb43a5-b365-4ebf-93d5-f3b632f29f33/792750756.png" alt="" />

Next, configure email settings:

HP_NO_IMG/data/uploads/users/7ecb43a5-b365-4ebf-93d5-f3b632f29f33/908992468.png" alt="" />

Once you are finished, you can log into your Mautic marketing automation platform as below:

HP_NO_IMG/data/uploads/users/7ecb43a5-b365-4ebf-93d5-f3b632f29f33/1994279555.png" alt="" />

That's it..