Mautic is an open source, self-hosted marketing automation software, you only need a LAMP stack to run it. With the help of Mautic you can create and easily manage, automate email and SMS campaigns.
It is a robust solution, if you are serious about marketing, you should try it!
Here is a complete tutoral and video guide, how to set up Mautic on your freshly installed Ubuntu server.
You’ll need 16.04 or 18.04 LTS operating system. We will create an Apache2, MariaDB and PHP 7.1 environment to run our Mautic.
Set up mautic
List of commands
Here are the list of commands you need to use during the installation process:
Install Apache:
sudo apt update
sudo apt install apache2
You will be able to stop, restart and enable Apache with the following commands:
sudo systemctl stop apache2.service
sudo systemctl start apache2.service
sudo systemctl enable apache2.service
Now you can test if the install was successful, enter the IP address of your server and see if the Apache test page is displayed:
Now, let’s install the database server as well, we will go with MariaDB open source MYSQL server.
sudo apt-get install mariadb-server mariadb-client
This is how you start and stop MariaDB on Ubuntu 16.04 LTS:
sudo systemctl stop mysql.service sudo systemctl start mysql.service sudo systemctl enable mysql.service
This is how you start and stop MariaDB on Ubuntu 18.04 LTS:
sudo systemctl stop mariadb.service sudo systemctl start mariadb.service sudo systemctl enable mariadb.service
Once we installed the database, let’s secure our installation.
sudo mysql_secure_installation
When prompted, answer the questions below by following the guide.
- Enter current password for root (enter for none): Just press the Enter
- Set root password? [Y/n]: Y
- New password: Enter password
- Re-enter new password: Repeat password
- 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
Restart MariaDB server
sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
Log in with your previously created password. (You’ll be propted):
sudo mysql -u root -p
If your installation was successful, you should see something like this:
Now we will create the proper server environment, install php 7.1 and all modules needed to run Mautic smooth and fast.
First we do a repo-upgrade and update to php 7.1
sudo apt-get install software-properties-common sudo add-apt-repository ppa:ondrej/php
sudo apt update
Now, we can add the 7.2 related php modules:
sudo apt install php7.1 libapache2-mod-php7.1 php7.1-common php7.1-gmp php7.1-curl php7.1-intl php7.1-mbstring php7.1-xmlrpc php7.1-mysql php7.1-bcmath php7.1-gd php7.1-xml php7.1-cli php7.1-zip
It’s time to tweak some php settings, let’s open php.ini:
sudo nano /etc/php/7.1/apache2/php.ini
Some of these settings will be already set as below, but you still need to make all the necessary changes.
You can anytime search in the file editor with CTRL+W.
file_uploads = On allow_url_fopen = On short_open_tag = On memory_limit = 256M upload_max_filesize = 100M max_execution_time = 360
regarding your time zone, you can look up the matching value here.
Example:
date.timezone = Europe/Budapest
When you finished, you can close the file with CTRL+X and Y + Enter
It is time to restart Apache to validate all changes.
sudo systemctl restart apache2.service
In order to make sure all changes are applied, we will create a page, that displays php information of our newly created apache webserver. It is very useful in case we need to debug.
sudo nano /var/www/html/phpinfo.php
A new file is opened. Add this php code in the first line.
<?php phpinfo( ); ?>
(Again: CTRL+X and Y+Enter to save.)
Now enter the following address into your browser:
http://YOUR-IP/phpinfo.php
where YOUR-IP is your actual IP address. You should see PHP default test page…
Create Database
Create Database for Mautic
Create database for our Mautic installation
Mautic needs a database to run, so we will make an empty database first.
We need to log in into our MariaDB database server, with the following commands below.
sudo mysql -u root -p
Then create a database called mauticdb
CREATE DATABASE mauticdb;
Create a database user called mauticuser with new password. This is a password, which will be used for especially this database. Do not use your root password.
CREATE USER 'mauticuser'@'localhost' IDENTIFIED BY 'yourpsw';
Then grant the user full access to the database. (Make sure you use the password you just gave above)
GRANT ALL ON mauticdb.* TO 'mauticuser'@'localhost' IDENTIFIED BY 'yourpsw' WITH GRANT OPTION;
We are done, save your changes and exit.
FLUSH PRIVILEGES; EXIT;
Install Mautic via Github
INSTALL GITHUB
In order to have an always up-to-date environment for Mautic, we will use Github for the installation.
Let’s install Composer, Curl and everything else needed.
sudo apt install curl git curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
Now we will clone Mautic from Github. Then ee need to change our directory to our final Mautic directory.
cd /var/www/html sudo git clone https://github.com/mautic/mautic.git cd /var/www/html/mautic sudo composer install
Mautic needs proper ownership and file permissions to run. Now run the commands below to set the correct permissions.
sudo chown -R www-data:www-data /var/www/html/mautic/ sudo chmod -R 755 /var/www/html/mautic/
Configure Apache2
Finally, configure Apahce2 site configuration file for Mautic. This file will control how users access Mautic content. Run the commands below to create a new configuration file called mautic.conf
sudo nano /etc/apache2/sites-available/mautic.conf
Then copy and paste the content below into the file and save it. Replace the highlighted line with your own domain name and directory root location.
<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www/html/mautic ServerName yoursite.com ServerAlias www.yoursite.com <Directory /var/www/html/mautic/> Options +FollowSymlinks AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Save the file and exit. You know now how by now 🙂
Enable the Mautic and Rewrite Module
Once you configured the VirtualHost as above, you’ll need to enable it by running following the commands:
sudo a2ensite mautic.conf sudo a2enmod rewrite
After restarting Apache2 all the settings will be updfated.
sudo systemctl restart apache2.service
Add SSL to our website
In order to inbox better and get better results with email marketing you’ll need to add SSL to your site. We will use certbot and letsencrypt for that. Let’s add repositories and dependencies:
sudo add-apt-repository ppa:certbot/certbot
sudo apt install python-certbot-apache
We can check if our virtual servers are properly configured:
sudo apache2ctl configtest
If it passes the test (You get an OK answer), than you can move on. Otherwise check your virtual server settings for a typo.
Restart Apache2:
sudo systemctl reload apache2
Now we should run certbot. You can add multiple domains and subdomains:
sudo certbot --apache -d mywebsite.com -d www.mywebsite.com
In order to check if our SSL is online, we can run a test:
sudo certbot renew --dry-run
Now, open your browser and browse to your domain name. You should see Mautic setup wizard.
You supposed to see something like the following screenshot:
It is possible, that you’ll see some environmental recommendations. We can talk about them later. If you don’t see anything red, we are good to go. Click on Next step.
Fill out the fields with the user names and passwords we used previously.
Now we need to create the credentials of our main admin user.
Congratulations, you are done!