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://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://mirror.lstn.net/mariadb/repo/10.5/ubuntu 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>
ServerAdmin admin@yoursite.com
DocumentRoot /var/www/html/mautic
ServerName 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>
Add SSL
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 subdomain.yourdomain.com
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 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 'YOURSTORNGPSW';
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 'YOURSTRONGPSW' WITH GRANT OPTION;
We are done, save your changes and exit.
FLUSH PRIVILEGES;
EXIT;
Download Mautic
Let’s download the newest version from Github
mkdir /var/www/html/mautic
cd /var/www/html/mautic
wget https://github.com/mautic/mautic/releases/download/4.0.0/4.0.0.zip
unzip 4.0.0.zip
rm 4.0.0.zip
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:

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

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

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/mauticcrons.sh
I have a fine tuned cron script, but you can change each element if you know what you are doing:
#!/bin/bash
MAUTICCONSOLE="/var/www/html/mautic/bin/console"
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
else
php $MAUTICCONSOLE mautic:broadcasts:send --limit=200
php $MAUTICCONSOLE mautic:emails:send --message-limit=200
fi
Save it, and open the crontab:
crontab -e
Add the script to the cron and run it every minute:
* * * * * /bin/bash /usr/local/bin/mauticcrons.sh
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!
Hi, great that it worked for you. What I meant is: you know how to save the file in NANO.
Thanks, but which file?
I was referring to the nano /usr/local/bin/mauticcrons.sh file
I used vi instead of nano, I really hate nano.
It is a question of taste really ๐
Before creating databases, needs the command “mysql -u root”. I thought I made a mistake and see your video and reinstall it.
Yeah, permissions are tricky. That all depends what your user is.
Thank you for the instruction.
It’s really helpful.
I notice there is one dash is missing for
mautic:maintenance:cleanup โdays-old=365
It should be
mautic:maintenance:cleanup โ-days-old=365
Thanks. You are right, it is a nicer format. I tested and both works actually.
Thx, appreciate the backlink.
Thanks Joey. How about a simple tutorial similar for upgrading from 3.3.#?
Challenge accepted. Friday Sept 4th is the day when I finish the 10th upgrade, so I’ll have some experience by then.
Hey, the update tutorial is posted now:
https://joeykeller.com/update-mautic-3-to-mautic-4-via-ssh/
Great guide indeed Joey!
Thank you Sir ๐
Was really fantastic. I have just installed Mautic 4.0 successfully, although SSL still missing but I think this is because DNS has to propagate, will do it tomorrow.
Many Thanks!
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.
Hi,
Sorry that you have trouble. Does your subdomain resolve to Mautic? You said you can see a Mautic logo. Did you install successfully?
Hello, yes I installed it successfully, but after the installation it says page not found.
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?
Thanks Joey, this was helpful.
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?
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.
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….
I don’t think it’s a waste, the server is there to serve. Work for that juice little CPU!
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?
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 Friendly.ch 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.
Hello , nice tutorial !! Appreciate it !
Is it the same tuto if i’m using UBUNTU 20.04 please ? Thank you !
Should be no different. But there are other tutorials covering it as well.
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
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.
Joey
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:
https://github.com/doctrine/DoctrineBundle/issues/673
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…
Hello Andres,
Your sql password is not correct here, but I can see your next comment, you fixed it ๐
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!
Regards
Hello Andres,
There is a video. Your issue was probably this: https://youtu.be/Pz8vLl-Lmww
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.
Joey,
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?
Usually setting the permissions right and clearing the cache would help.
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
Hello!
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.
Thank you very much for your quick responce.
1) I tried to send an email to xyz@gmail.com 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!
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
Best
The condition means – your spool is empty. So I’m not even trying to send ๐
Thanks for sharing,
question: what do you know about Mailgun plugin for this version?
Hi, have you tried this?
https://github.com/nextgi/MauticMailgunBundle
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
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.
Hey man, great stuff, but why aren’t you using composer? Doesn’t it bring more functionality? Like the Market Place?
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.