Here is a simple step by step guide about installing Mautic 4 on a clean Ubuntu 18.04 server. Enjoy.

Watch the video or enjoy the step by step guide with all the commands you need below.

Install prerequisites

Configure your timezone

dpkg-reconfigure tzdata

Install PHP prerequisits

sudo apt -y install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

Install required packages

apt install apache2 libapache2-mod-php7.4 php7.4 unzip php7.4-xml php7.4-mysql php7.4-imap php7.4-zip php7.4-intl php7.4-curl php7.4-gd php7.4-mbstring php7.4-bcmath ntp -y

Install MariaDB 10.5

This method will install from the official repo:

sudo apt-key adv --recv-keys --keyserver hkp:// 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] bionic main'
sudo apt update
sudo apt install mariadb-server

Configure Apache2

Configure Apache2 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>
     DocumentRoot /var/www/html/mautic

     <Directory /var/www/html/mautic/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined



sudo add-apt-repository ppa:certbot/certbot
apt update && apt upgrade -y

sudo apt-get install python-certbot-apache

Initiate Certbot setup

certbot --apache -d

Once you configured the Virtual Host as above, you’ll need to enable it by running following the commands:

sudo a2ensite mautic.conf
sudo a2enmod rewrite

Tweak PHP settings

sudo nano /etc/php/7.4/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 = 300
post_max_size = 200M
date.timezone = "Europe/Zurich"

(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

Create our database

Once we installed the database, let’s secure our installation.

sudo mysql_secure_installation

When prompted, answer the questions below as follows:

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

Stop and restart the server

sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service

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.


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.


Then grant the user full access to the database. (Make sure you use the password you just gave above)


We are done, save your changes and exit.


Download Mautic

Let’s download the newest version from Github

mkdir /var/www/html/mautic
cd /var/www/html/mautic

Reset ownership and permisssions

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

Reload Apache

service apache2 reload

Save the file and exit. You know now how by now πŸ™‚

Install Mautic

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:

Mautic 4 Installation environment check

If you don’t see anything red, we are good to go. Click on Next step.

Mautic 4 installation setting database access

Fill out the fields with the database nane, database user name and passwords as set previously.

Mautic 4 installation user login settings

Now we need to create the credentials of our main admin user.

You can specify the SMTP settings here, but that differs based on your SMTP service provider. You can also leave it empty and click on next.

Hopefully you will see a login screen. Congratulations. You are almost done!

Add cronjobs

I like to run my cron commands sequentially, and this is why I add them to a single file.

nano /usr/local/bin/

I have a fine tuned cron script, but you can change each element if you know what you are doing:



if [ -z "$(ls -A /var/www/html/mautic/var/spool)" ]; then

	php $MAUTICCONSOLE mautic:broadcasts:send --limit=50
	php $MAUTICCONSOLE mautic:campaigns:rebuild --batch-limit=300
	php $MAUTICCONSOLE mautic:segment:update --batch-limit=900
	php $MAUTICCONSOLE mautic:campaigns:trigger
	php $MAUTICCONSOLE mautic:import --limit=500
	php $MAUTICCONSOLE mautic:webhooks:process
	php $MAUTICCONSOLE mautic:reports:scheduler
	php $MAUTICCONSOLE mautic:maintenance:cleanup --days-old=365

	php $MAUTICCONSOLE mautic:broadcasts:send --limit=200
	php $MAUTICCONSOLE mautic:emails:send --message-limit=200

Save it, and open the crontab:

crontab -e

Add the script to the cron and run it every minute:

* * * * * /bin/bash /usr/local/bin/

Enjoy, you are ready!


53 Comment

  • Daniel Wood


    Thanks, your guide is clear and straightforward: even I was able to follow along and get it to work (I think). My only stumble was right between changing the permissions for the Mautic folder and going to the webpage and finishing up the install via browser.
    You have

    “Save the file and exit. You know now how by now”

    I wasn’t sure which file, hoping I haven’t missed anything crucial.

    Thanks again for the guide!

  • jayson eballena


    Hi Joey! great work I followed your guide and successfully installed it.
    But the problem is that, I already put the domain name as the serverName and added ssl certificate to the subdomain just like you mentioned, but still when I access the url it says “URL not found” with the mautic logo and mautic 404 page. Just for info also, I also set AllowOverride to all. Thanks for the help.

    • jos0405


      Sorry that you have trouble. Does your subdomain resolve to Mautic? You said you can see a Mautic logo. Did you install successfully?

    • jos0405


      Hello Jason,
      Did you apply SSL? What is the exact error you see? Is it like 404 Page not Found, Domain not found or 503 Connection error?

  • Andres Berger


    I finished this installation. Thank you Joey for this, really appreaciate this.

    But. running every cron simultaneously every minute is not against the recommendations? will not be excessive burden for the VPS?

    • jos0405


      Hallo Andreas!
      The goal is to make sure you set limitations for running the cron in such a way, that all scripts are ending within 1 minute.
      This way if you are running them every min, you’ll be totally fine.

      • Andres Berger


        Still. Why don’t run them every hour or so and 10 minutes gaps between them, most of us are not super desperate to send the email super fast.

        if your email is not transactional, then running all crons every minute is wasting a lot of server resources…. I think….

  • Willie


    What’s better: this way or docker? I’m seeing more and more FOSS platforms push docker as the default install method. Are there any advantages to this non-containerized install?

    • jos0405


      Hi, you can do this in a linux container if you want, the commands are the same.
      If you know how to work with docker, there is no reason why not to use it. We at are using LXC containers.
      I’m a huge fan of containers, I containerise everything πŸ™‚ But managing containers need more skills, it’s not for everyone.

  • Antenaina Flavio Steven Rakotoarivelo


    Hello , nice tutorial !! Appreciate it !
    Is it the same tuto if i’m using UBUNTU 20.04 please ? Thank you !

  • Victor Hugo


    Hi joey is it possible to do this installation without using https? in this case the certificate? I have an error that I can’t get past the first post installation step

    • jos0405


      There are many ways to add SSL, and you should definetly do it.
      I didn’t add to this tutorial, but you can find many good guides out there. Any SSL tutorial will do.

  • Andres



    That cron jobs doesn’t work. Campaigns are only sending the first email.
    I tried to run one of the crons manually like this:

    php /var/www/html/mautic/bin/console mautic:campaigns:trigger

    and got:


    In ConnectionFactory.php line 134:

    An exception occurred while establishing a connection to figure out your platform version.
    You can circumvent this by setting a ‘server_version’ configuration value

    For further information have a look at:

    In AbstractMySQLDriver.php line 112:

    An exception occurred in driver: Access denied for user ‘tjzkuwtj_maut698’@’localhost’ (using password: YES)

    In ConnectionFailed.php line 19:

    Access denied for user ‘tjzkuwtj_maut698’@’localhost’ (using password: YES)


    I will read the thing on Github, but I never created those database users…

  • Andres


    Hi Joey

    There is one more crazy stuff to add to Mautic.

    I found in some place that maybe changing the type of sending from marketing to transaccional could make the difference and really did, I received the complete sequence of emails after changing that…. (I was in the verge of deleting Mautic and the server)

    Previously I was wondering why the tracking button not worked and I thought maybe the variable is stored within the emails themselves, so deleted all emails, recreated them and the click tracking was gone (Google really hate those, so I prefer to not track than client not being able to open the links sent).

    There should be a video explaining users all these potential problems when you are on your way to test Mautic in order to not go crazy.

    And by the way, your crons work correctly!


    • jos0405


      Hello Andres,
      There is a video. Your issue was probably this:
      Your emails were queued up due to daily email limit settings.
      Regarding the tracking: I’m talking about how to test your emails and how the admin cookie changes the way you experience Mautic.
      Check my free course, it’s in there.

  • John Tourgee


    Thanks for this tutorial! Every thing seemed to work but I ended up with at the “I broke it” screen and no logs. where do I start to look to fix it?

  • Chirayu


    Hi… Thank you for this step-by-step guide. It is really very helpful for a person like me, who is non-technical.
    I followed your every step as it is and installed the 4.2.1 version of mautic. And unable to active SSL due to crossing the limit of 5 certi per week. So right now I am handling mautic through http://myipaddress
    Now I am facing 2 problems:
    1) Showing OPEN EMAIL, even without opening it! And it triggers the next action set in the campaign.
    2) Not able to track landing page visits and WordPress website visits (After setup of “Tracking Setting”)
    3) It’s Take too much time to load the “configuration” page
    (Not showing any error in log file)

    My server @ AWS
    Instance Type: t3a.small | vCPUs : 2 | Memory(GiB): 2

    Please guide me. Thank you

    • jos0405


      Once you pass the 5 = week limit it will be okay. Just redo your SSL, and try not to mess up πŸ™‚
      1. This happens on apple devices. Nothing you can do about it. I wouldn’t base my campaigns on email opens.
      2. This happens because you don’t have SSL
      3. This can happen if you have a slow instance. 2 GIG / 2 CPU is small.

      • Chirayu


        Thank you very much for your quick responce.
        1) I tried to send an email to and it was android based mobile. The sender’s and receiver’s both devices were NON-APPLE devices. Though facing the same problem.
        2) Ok. Got it.
        3) Can you guide me that which instance type is more suitable to handle 5k contact?

        Thank you again!

  • Nicolas Jardillier


    Hi and thanks for sharing a lot πŸ˜‰

    In the cron script, why there is not :
    php $MAUTICCONSOLE mautic:emails:send

    in the condition :
    if [ -z “$(ls -A /var/www/html/mautic/var/spool)” ]; then


  • erico


    Hello Joey

    Im using aaPanel adding a shell script but getting this weird error

    | Channel | # sent | # failed |
    Webhook Bundle is in immediate process mode. To use the command function change to command mode.
    Scheduler has finished
    This will permanently delete data older than 365 days! Please make a backup before proceeding. Run this command with –dry-run to get approximate records to be deleted. Continue? (y/n) —————————————————————————-
    β˜…[2022-11-10 19:56:08] Successful

  • jos0405


    This is not an error.
    It happens when you run the cleanup script.

    | Channel | # sent | # failed |
    will only be populated if you send emails. So you would see the numbers under the respective columns.

  • Garret Acott


    Hey man, great stuff, but why aren’t you using composer? Doesn’t it bring more functionality? Like the Market Place?

    • jos0405


      Hey, for 2 reasons:
      1. this article is before Marketplace was launched.
      2. composer update is bumpy at the momment (2022.DEC), you might delete you whole Mautic db upon a composer update.

  • Rahul


    Hi i have installed mautic 4.1 in ubuntu 22.04 via nginx
    evrything seems to be fine the test emails are going out but when i create a segment email and send it out its just gets stuck and the emails are not sent out im not able to figure out the issue
    here are my cron jobs:
    */5 * * * * /usr/bin/php8.0 /var/www/mautic/bin/console mautic:segments:update > /dev/null 2>&1
    */15 * * * * /usr/bin/php8.0 /var/www/mautic/bin/console mautic:webhooks:process > /dev/null 2>&1
    */10 * * * * /usr/bin/php8.0 /var/www/mautic/bin/console mautic:leadlists:update > /dev/null 2>&1
    */10 * * * * /usr/bin/php8.0 /var/www/mautic/bin/console mautic:campaigns:update > /dev/null 2>&1
    */5 * * * * /usr/bin/php8.0 /var/www/mautic/bin/console mautic:campaigns:trigger > /dev/null 2>&1
    */10 * * * * /usr/bin/php8.0 /var/www/mautic/bin/console mautic:social:monitoring > /dev/null 2>&1
    */5 * * * * /usr/bin/php8.0 /var/www/mautic/bin/console mautic:emails:send > /dev/null 2>&1
    0 0 * * * /usr/bin/php8.0 /var/www/mautic/bin/console mautic:fetch:email > /dev/null 2>&1
    0 0 * * * /usr/bin/php8.0 /var/www/mautic/bin/console mautic:iplookup:download > /dev/null 2>&1
    */15 * * * * /usr/bin/php8.0 /var/www/mautic/bin/console mautic:campaigns:rebuild > /dev/null 2>&1
    */15 * * * * /usr/bin/php8.0 /var/www/mautic/bin/console mautic:reports:scheduler > /dev/null 2>&1
    */15 * * * * /usr/bin/php8.0 /var/www/mautic/bin/console mautic:email:process > /dev/null 2>&1

    can u please help


Leave a Reply to Daniel Wood Cancel reply

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