Install Mautic on Ubuntu

Install Mautic – Ubuntu Linux, Nginx and Free SSL [With Video Steps]

In this tutorial I’ll describe in detail how you can install Mautic on Ubuntu using Nginx (webinoly setup) and Free SSL from Let’s Encrypt. The steps are easy to follow, I’ll provide screenshots as well. The following are the steps I am going to describe in this tutorial. All the commands will be provided in order of use and for the ease of copy pasting.

  1. Create a Linux instance using any hosting, Digital Ocean, Lightsail, EC2 whichever is your favorite. [I’ll use Ubuntu on Lightsail].
  2. Install webinoly, a complete package of LEMP with optimized cache and certbot support.
  3. Create a PHP-MySQL virtual host, using webinoly site command.
  4. Download and unzip Mautic package in the server-root directory.
  5. Set proper file and directory permissions.
  6. Access domain and follow on screen steps to configure the Mautic.
  7. Set up Cron Job recommended by Mautic.
  8. Add Email credentials and be ready to send emails. [I am using Amazon SES for Emails].

What Do I need to know to install on Mautic by myself ?

If you are a non technical guy and some commands are coming again and again in search results it can be tough to identify how and in what order to use them. In this section I’ll answer some basic questions to prepare you for Mautic installation.

To Install Mautic, you should have basic knowledge of Domain, Hosting and web servers. Any basic knowledge of Linux command terminal is a bonus. If you’re just able to copy paste the commands and understand output text that is fine too.

  • You should know what is Domain and Web server.
  • You should know basic about files and directories navigation in Linux.
  • You should know how to run commands in Linux and if needed how to use sudo.

Do I need to know Linux Commands to Work with Mautic ?

You don’t need to know everything about Linux commands but few things will come your way. In the article I am providing all the commands you will need to use but a basic understanding of how to move around Linux terminal is required. By following this tutorial you don’t need to know Linux in order to install Mautic.

How to set up Mautic Cron Jobs ?

Mautic cron jobs are background script which will run on Linux server at defined time and will execute some commands to trigger campaigns, email and few other actions in Mautic. To set up Mautic command you need to know how often you need to trigger these command and one time setup is required, For this crontab command can be used in Linux or in case of cPanel you can use cron manager to add these commands, In the tutorial I will explain how to set up crontab very easily by just copy pasting the code from this blog.

How to Install Mautic on Ubuntu ? – Complete Tutorial for Beginners, Step by Step with screenshots

Okay, enough of introduction, let’s get started, I am using Lightsail to create Ubuntu instance, Nginx as web server and Let’s encrypt for SSL provider.

Create Ubuntu Instance and Map Domain

To install Mautic we need a web domain, if you have a Web-domain and would like to use Lightsail you can use the tutorial I have created on How to map godaddy domain to amazon route 53, or you can map domain to the Lightsail instance.

Here is a step by step brief in order to give you crash course:

  • Create Instance in Lightsail.
    • Click on Create Instance.
    • Select the OS Only.
    • Select Ubuntu 20.04 LTS
    • Choose the Pricing Plan, I recommend at least 1 GB RAM.
    • Give this instance a Name.
    • Click Create Instance.
    • The Instance will now be created, Wait few minutes, Until the Instance Is Up.
Create Ubuntu Instance in Lightsail
  • Open the SSL Port in Instance Network
    • Click on the Instance Name.
    • Under the IPv4 click + Add rule.
    • From the first field choose the SSL and click Create.
    • Now the port will be open and available for the SSL.
  • Create Domain mapping
    • Go to networking tab.
    • Click on DNS Zone. [Refer to this tutorial for more information.]
    • Add subdomain or Domain as A record as per your situation, for domain ‘@’ and for subdomain ‘subdomain-name’ in the field.
    • Choose the instance from the drop down.
    • Click green check icon.
Create DNS Mapping for Instance
  • Connect to Instance
    • Click on Connect tab.
    • Click on Connect using SSH button.
    • It will open a browser based terminal where you can copy paste the commands in order to prepare your setup.
Connect To lightsail terminal in browser
  • This is it about Lightsail part, now let’s start with command now.

Install Webinoly – Prepare Linux Instance for Mautic Installation

Webinoly is an optimized web server package which provide, almost every you will need to set up Mautic, and you will not need to install package one by one. To install webinoly you will only need to go to webinoly website and copy paste the first command you find on the page, the command is given below as well.

#install webinoly
wget -qO weby qrok.es/wy && sudo bash weby 3

It’ll take some time but it’ll install everything you need, Nginx, PHP, MySQL, certbot, PHP packages and optimize the system in best way to run Nginx.

Once the installation is complete you will receive the root password, copy it and keep it safe for later use whenever you will need.

Create the Virtual host on Nginx

To create virtual host you don’t need much, webinoly is there and it’ll help you with simple command. What you need is a virtual host with a root directory and MySQL database. to do that, you need to run simple command.

The argument -mysql tells webinoly that you need a PHP virtual host with MySQL support, and it’ll create one for you immediately.

At the end this command will show MySQL username and password created for this site, please copy and keep it safe it’ll be used when Mautic installation is done.

#create a site on webinoly using domain you configured on DNS Zone
sudo site mauticdemo.mayanktiwari.in -mysql

To verify if your space is ready you can use simple command sudo site -list , this will show you the site you have just created. In my case mauticdemo.mayanktiwari.in. In the list you will see that it shows there is no SSL as of now, In the next section I describe how to obtain free SSL certificate from Let’s Encrypt.

Install SSL Certificate with Certbot and Let’s Encrypt

To Install the certificate you don’t need to buy one, Let’s Encrypt is an organization which is helping everyone secure their content online with their free SSL Certificate. To do the same you will need only to run a simple command, just like last one with parameter -ssl=on .

sudo site mauticdemo.mayanktiwari.in -ssl=on

it’ll ask for the email where it can send notification for expiration notice so you can be ready to renew on time. After this cert bot will verify the domain and then configure SSL for the domain.

Webinoly part is now done next step is to prepare the server, Download and install Mautic.

Setting rights and permissions for Mautic Installation

Before starting with Mautic installation, let me show you some minimal steps which will help a lot for smooth processing of the installation. What I do and what I recommend to do is to pre-configure file and directory permissions.

You will notice the username in linux you get is ubuntu. So what you will need to do is, add this linux user to the Nginx and php-fpm group and then give directories right permissions. I am listing the steps and then commands in order of execution.

  • Add ubuntu to www-data group.
  • Own the installation directories.
  • Give right read-write-execute permission to user and group.
  • Move to directory which is serving as root of virtual host.
  • Download Mautic zip directory.
    • Visit Mautic git hub repository tags page.
    • Choose the version you want to install and click on it. [3.3.3 in this case]
    • Scroll to bottom of the page and copy the link of the zip file. [3.3.3.zip]
    • Run the download command as shown in the code list below.
  • Extract files.
  • Assign proper permission to all Mautic files and directories.
#add ubuntu to group www-data
sudo usermod -a -G www-data ubuntu

#check groups of ubuntu, it should show www-data as one of the groups
id ubuntu

#enter www directory
cd www

#Assign file and directory rights to ubuntu for ease of use
sudo chown -Rf ubuntu:www-data mauticdemo.mayanktiwari.in

#assign right permissions to ubuntu and group www-data
sudo chmod -Rf 775 mauticdemo.mayanktiwari.in

#move to htdocs directory
cd mauticdemo.mayanktiwari.in/htdocs

#download mautic 3 from the URL you choose. 
wget https://github.com/mautic/mautic/releases/download/3.3.3/3.3.3.zip

#unzip files
unzip 3.3.3.zip

#give proper permissions to files and directories
sudo find . -type d -exec chmod 775 {} \;
sudo find . -type f -exec chmod 664 {} \;

The commands above should prepare your server for in the browser installation steps.

Install Mautic – in browser steps

  • Open the domain in browser now. [The domain you configured in DNS zone and created site in webinoly]
  • You will see Mautic installation first step, requirement check screen, it should be okay with webinoly setup already unless there is any red sign.
  • Next step will be to enter details of database, here you will need to enter the details which webinoly provided at the time of site creation. Ideally webinoly uses site name for username and database name and a secured password.
  • On Next screen choose and enter username and password for first user along with Name and Email.
  • Next step asks for the SMTP details, you can skip it for now, I’ll show how to add this from configuration section of Mautic.
  • You should land on the dashboard of Mautic with successful installation of Mautic.

Configure Cron Jobs

Mautic installation is incomplete without setting cron jobs. Cron Jobs are some commands, scheduled to run at certain pre defined time. It can be once or more or even every minute. to easily create a cron time pattern you can use crontab guru.

So let’s get back to the command terminal used previously and do execute some more commands.

  • Enter the crontab edit mode for user www-data which is user controlling nginx and php-fpm.
  • Enter the commands in the order given below.
  • Use pwd command to obtain path to current directory. It should look something like /home/ubuntu/www/you-domain-name/htdocs.
  • crontab -u www-data -e will enter the cron edit mode.
  • First time it’ll ask to choose the editor go with nano it is the easiest one.
  • Copy paste the cron commands from the code snippet below, this issetting the commands to execute at certain interval. [Ensure to change the path in example by the path obtained by pwd command and do append /bin/console at the end]
  • For example First command is set to execute at 0, 10, 20, 30, 40, 50 minutes of each hour of each day or each week of each month and it executes the command using php on the path /home/ubuntu/www/mauticdemo.mayanktiwari.in/htdocs/bin using binary console to execute Mautic console command named mautic:segment:update.
  • Each command should be at its own line so ensure the formatting.
  • Finally use ctrl+o [English letter O] to save.
  • Use ctrl+x to close and install the crontab changes.
Install Cron Jobs for Mautic
#use pwd to obtain current working directory path
pwd

#enter crontab edit mode for www-data user
sudo crontab -u www-data -e

#copy the cronjobs and add to editor, make sure to change the path to use your domain name instead of mautic.mayanktiwari.in
0,10,20,30,40,50 * * * * php /home/ubuntu/www/mauticdemo.mayanktiwari.in/htdocs/bin/console mautic:segments:update
5,15,25,35,45,55 * * * * php /home/ubuntu/www/mauticdemo.mayanktiwari.in/htdocs/bin/console mautic:campaigns:rebuild
2,12,22,32,42,52 * * * * php /home/ubuntu/www/mauticdemo.mayanktiwari.in/htdocs/bin/console mautic:campaigns:trigger
3,13,23,33,43,53 * * * * php /home/ubuntu/www/mauticdemo.mayanktiwari.in/htdocs/bin/console mautic:email:fetch
4,14,24,34,44,54 * * * * php /home/ubuntu/www/mauticdemo.mayanktiwari.in/htdocs/bin/console mautic:import
0,5,10,15,20,25,30,35,40,45,50,55 * * * * php /home/ubuntu/www/mauticdemo.mayanktiwari.in/htdocs/bin/console mautic:emails:send

That is it, the cron jobs are configured, now the last step is to configure email. for that you can go to Mautic settings and enter configuration section.

Configure Email SMTP for Mautic

  • I am using Amazon SES, you can easily find many resources on the same here is the link to one of the videos I find good.
  • Once the Credentials are available follow next steps.
  • Go to Settings > Configurations > Email Settings.
  • Enter the SMTP details here.
  • Click Test Connection to verify validity of connection.
  • Apply, and then Click Send test email to send a test email to your email, configured in Mautic.

Complete Video Tutorial

The Conclusion

Installation of Mautic is easy if you follow the steps described in this tutorial. All the commands given are tested and in order of the usage and should be sufficient from setting up the server to setting up Mautic and configuring the cron jobs as well as email.

For any queries feel free to comment or contact me using contact us page.

Leave a Comment

Your email address will not be published. Required fields are marked *