Install and Deploy Mautic on Ubuntu 24.04 with LEMP Stack

Mautic is a powerful open-source marketing automation solution that helps organizations manage customer engagement through email campaigns, contact monitoring, lead nurturing, and detailed reporting. As a self-hosted alternative to platforms like HubSpot or Marketo, it gives you complete control over your data and workflows.

This guide walks you through installing and deploying Mautic on an Ubuntu 24.04 server with the LEMP stack (Linux, Nginx, MySQL, PHP). Each component will be configured for production, preparing your server to run Mautic securely over the web.

Prerequisites

Before you begin, ensure that you have:

  • Access to an Ubuntu 24.04 server as a non-root user with sudo privileges.
  • A domain A record pointing to the server’s IP, such as mautic.example.com.

Install LEMP Stack

The LEMP stack (Linux, Nginx, MySQL, PHP) provides a fast and reliable platform for hosting PHP applications like Mautic. Follow the steps below to set it up and verify installation.

Refer to the LEMP stack installation guide to ensure Nginx, MySQL, and PHP are installed before proceeding.

Check Installed Nginx Version

Expected output:

nginx version: nginx/1.24.0 (Ubuntu)

Check Installed MySQL Version

Expected output:

mysql  Ver 8.0.41-0ubuntu0.24.04.1 for Linux on x86_64 ((Ubuntu))

Check Installed PHP Version

Expected output:

PHP 8.3.6 (cli) (built: Mar 19 2025 10:08:38) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.6, Copyright (c), by Zend Technologies

Install PHP Extensions Required for Mautic

$ sudo apt install php-fpm php-mysql php-imap php-curl php-json php-gd php-xml php-mbstring php-zip php-intl php-bcmath php-opcache php-cli unzip -y

Remove Apache if Installed

PHP installation may also bring Apache as a dependency. Remove it to avoid conflicts with Nginx:

$ sudo apt remove apache2 -y

Optimize PHP-FPM Settings

Edit the PHP-FPM configuration file (replace 8.3 with your installed version):

$ sudo nano /etc/php/8.3/fpm/php.ini

Update these values:

memory_limit = 512M
upload_max_filesize = 50M
post_max_size = 50M
date.timezone = UTC
cgi.fix_pathinfo=0

Restart PHP-FPM:

$ sudo systemctl restart php8.3-fpm

Create the Mautic Database

Mautic needs a database to store contacts, campaign activities, email logs, and configuration data. Follow these steps to set it up:

Access MySQL Console

Create Database and User

mysql> CREATE DATABASE mauticdb;
mysql> CREATE USER 'mauticuser'@'localhost' IDENTIFIED BY 'securepassword';
mysql> GRANT ALL PRIVILEGES ON mauticdb.* TO 'mauticuser'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;

Install Mautic

Now that the environment is ready, download and install Mautic:

Download and Extract Mautic

$ wget https://github.com/mautic/mautic/archive/refs/tags/6.0.0.zip
$ unzip 6.0.0.zip
$ sudo mv mautic-6.0.0 /var/www/html/mautic

Set Permissions

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

Install Composer and NPM

$ sudo apt install composer npm -y
$ composer --version
$ npm --version

Install Mautic Dependencies

$ cd /var/www/html/mautic
$ sudo -u www-data composer install
$ sudo chmod -R 755 /var/www/html/mautic

Configure Mautic

To make sure Mautic operates smoothly, you need to configure Nginx and set up cron jobs for background tasks. Follow the steps below to set up both.

Create Nginx Virtual Host

Create a new Nginx configuration file for Mautic:

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

Add the following configuration (replace mautic.example.com with your domain):

server {
    listen 80;
    server_name mautic.example.com;
    root /var/www/html/mautic;
    index index.php;
    access_log /var/log/nginx/example.com.access.log;
    error_log /var/log/nginx/example.com.error.log;       

    location / {
        try_files $uri /index.php$is_args$args;
    }

    location ~ .php$ {
         include snippets/fastcgi-php.conf;
         fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
         include fastcgi_params;
    }

    location ~ \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2)$ {
        expires 1y;
        access_log off;
        add_header Cache-Control "public";
    }
}

Test and Reload Nginx

$ sudo nginx -t
$ sudo systemctl reload nginx

Update Firewall Rules

Allow HTTP and HTTPS traffic:

$ sudo ufw allow 80/tcp
$ sudo ufw allow 443/tcp
$ sudo ufw reload

Enable SSL with Certbot

Install Certbot:

$ sudo snap install certbot --classic

Generate a free SSL certificate (replace with your domain and email):

$ sudo certbot --nginx --redirect -d mautic.example.com -m hello@example.com --agree-tos

Example successful output:

Deploying certificate
Successfully deployed certificate for mautic.example.com to /etc/nginx/conf.d/mautic.conf
Congratulations! You have successfully enabled HTTPS on https://mautic.example.com

Test auto-renewal of SSL certificates:

$ sudo certbot renew --dry-run

Set Up Cron Jobs for Mautic

Open the crontab for the web server user:

$ sudo -u www-data crontab -e

Add the following cron jobs:

# update segments every minute
* * * * * php8.3 /var/www/html/mautic/bin/console mautic:segments:update  > /dev/null 

# update campaigns every 15 minutes starting at 5 minutes past the hour
5-59/15 * * * * php8.3 /var/www/html/mautic/bin/console mautic:campaigns:update  > /dev/null 

# trigger campaign events every 15 minutes with 10-minute offset
10-59/15 * * * * php8.3 /var/www/html/mautic/bin/console mautic:campaigns:trigger  > /dev/null 

# process email queue
2-59/15 * * * * php8.3 /var/www/html/mautic/bin/console mautic:emails:send  > /dev/null

# import list in background
* * * * * php8.3 /var/www/html/mautic/bin/console mautic:import  > /dev/null

# fetch bounce messages
@hourly php8.3 /var/www/html/mautic/bin/console mautic:email:fetch

Use the Web-Based Mautic Installer

Once the server is configured, complete the setup using the browser-based installer.

Open your domain in a browser, e.g., https://mautic.example.com. You should see the Ready to install message.

Database Setup

Fill in your MySQL details:

  • Database Driver: MySQL PDO
  • Database Host: localhost (or your MySQL server IP)
  • Database Name: The database you created for Mautic
  • Table Prefix: Leave blank unless required
  • Database User: The MySQL user for Mautic
  • Database Password: The user’s password

Admin User Setup

Enter details for your Mautic admin account:

  • Admin Username: Your login name
  • Admin Password: A strong password
  • Email Address: A valid email for recovery and notifications

After completing the setup, log in with your admin credentials on the Mautic login page.

Access and Use Mautic

After logging in, the Mautic dashboard serves as the central hub for managing your marketing automation processes. From here, you can access contacts, emails, campaigns, forms, and more to track engagement and automate tasks. One important feature is Stages, which allows you to segment contacts based on their interactions and progress within the funnel.

Create and Manage Stages

Stages define a contact’s position within your funnel. You can assign stages based on actions, campaigns, or external triggers.

From the navigation menu, select Stages and click New. On the New Stage Action page, provide the following details:

  • Name: A descriptive name for the stage action.
  • Description: Explanation of the action and when it triggers.
  • Weight: Optional field for execution priority.
  • Category: Assign a category for better organization.
  • Active: Toggle to Yes or No depending on when to activate.
  • Activate at: Set a specific activation date/time.
  • Deactivate at: Set a deactivation date/time.

Click Save & Close to save the stage.

Create and Manage Companies

The Companies feature lets you associate multiple contacts with an organization. This is especially helpful in B2B scenarios.

Go to Companies in the sidebar and click New. On the New Company page, fill in:

  • Company Name
  • Company Email
  • Company Address
  • Score: Used in lead scoring.
  • Phone
  • Website
  • Company Owner

Click Save & Close to finalize.

Create and Manage Contacts

Contacts represent individual leads or customers. They can be tagged, segmented, and linked to companies.

Click Contacts in the sidebar and select Quick Add. On the New Contact page, provide:

  • First Name
  • Last Name
  • Email
  • Tags
  • Select a Company (if applicable)
  • Contact Owner
  • Stage

Click Save to store the contact.

Contact Segments

Segments are dynamic groups of contacts filtered by criteria. They auto-update when new contacts meet the conditions.

Go to Segments in the sidebar and click New. On the New Segment page, provide:

  • Name
  • Public Name
  • Description
  • Alias (auto-generated, editable)
  • Category
  • Visible to Other Users
  • Available in Preference Center
  • Active

In the Filters tab, define inclusion criteria, then click Save & Close.

Upload and Manage Assets

Assets are files such as PDFs, eBooks, images, or other content that can be shared with contacts.

Navigate to Components > Assets and click New. Choose storage type:

  • Local Storage: Upload directly from your computer.
  • Remote Storage: Link an external file.

Configure additional details:

  • Category
  • Language
  • Available for Use
  • Available From/Unavailable From
  • Block Search Engines

Click Save & Close when done.

Create and Manage Forms

Forms collect information, trigger actions, and enroll contacts into campaigns. There are two types:

  • Campaign Forms (used in campaigns)
  • Standalone Forms (used independently or embedded)

Go to Components > Forms and click New. Enter:

  • Name
  • Form Attributes
  • Description

Configure submission actions:

  • Display Message
  • Redirect URL/Message

Additional settings include category, availability, indexing, kiosk mode, theme style, and default language. Under the Fields tab, add form fields. Under the Actions tab, define post-submission actions such as sending emails or tagging contacts.

Click Save & Close to publish.

Create and Manage Landing Pages

Landing Pages are standalone pages for specific campaigns such as webinars or downloads. They can be designed with themes or the visual builder.

Go to Components > Landing Pages. Choose a theme or use the visual page builder. Configure:

  • Title
  • Alias
  • Category
  • Language

Advanced settings include translation references, availability, preference center role, and scheduling. Use the builder to add elements such as text blocks, images, forms, and HTML.

Click Save & Close to finalize.

Create and Manage Campaigns

Campaigns automate workflows based on contacts’ actions, decisions, and conditions. They are essential for lead nurturing and engagement.

Go to Campaigns and click New. Enter:

  • Name
  • Description

Configure:

  • Category
  • Allow Contacts to Restart
  • Active
  • Activate at / Deactivate at

Click Launch Campaign Builder to design workflows using drag-and-drop. Elements include:

  • Sources: Segment membership, form submissions
  • Actions: Send emails, update points
  • Decisions: Email opened, link clicked
  • Conditions: Match contact fields

Click Save & Close to save and activate the campaign.

Create and Manage Emails

Emails in Mautic are used to send newsletters, drip campaigns, transactional notifications, and campaign-specific content to your contacts.

Navigate to Channels > Emails and click New. Choose the type of email:

  • Triggered Email: Used in campaigns, forms, or point events. Can be sent multiple times and is ideal for transactional communication.
  • Segment Email: Suitable for newsletters, announcements, or one-time messages to specific segments.

Select a theme for your email and click Builder to open the visual editor for layout and content design.

Configure Email Settings

Under the Advanced tab, specify:

  • From Name: Sender name shown to recipients.
  • From Address: Email address used as the sender.
  • Reply-to Address: Optional reply address.
  • BCC Address: Receive blind copies of sent emails.
  • Attachments: Add files to include in the email.
  • Custom Headers: Extra headers for tracking or delivery management.

In the right pane, enter:

  • Subject: The email subject line.
  • Internal Name: Identifier for the email inside Mautic.
  • Preheader Text: Preview text displayed by many email clients.
  • Category: Assign to a category for better organization.
  • Language: Define the content language.
  • Is a Translation of: Select original email if this is a translation.
  • Available for Use: Toggle email availability.
  • Unsubscribe Feedback Form: Link to an unsubscribe form if available.

Click Save & Close to finish.

Create and Manage Point Actions

Point Actions let you assign or deduct points when contacts perform specific activities, helping score and rank leads by engagement.

Navigate to Points > Manage Actions and click New. Enter:

  • Name: e.g., “Download eBook” or “Visit Page”.
  • Description: Internal description of the action.
  • Change points (+/-): Define points added or removed (e.g., +10 for downloading an eBook).
  • Action taken by contact: Specify which interaction triggers the action (e.g., page visit, form submission).

Configure activation options:

  • Category: Assign a category for organization.
  • Active: Enable or disable the action.
  • Is repeatable: Decide if the action can be triggered multiple times.
  • Activate at / Deactivate at: Set specific times for activation and deactivation.

Click Save & Close to save the action.

Create and Manage Point Triggers

Point Triggers automate responses once a contact’s point threshold is reached, such as sending alerts, updating contact data, or assigning them to a segment.

Navigate to Points > Manage Triggers and click New. Provide:

  • Name: Clear label describing the trigger.
  • Description: Explain what it does.
  • Minimum number of points: The point threshold needed.
  • Contact color: Assign a color for easier segmentation in the dashboard.

Define behavior:

  • Trigger for existing applicable contacts upon saving: Decide if the trigger applies to existing contacts immediately.
  • Active: Enable or disable the trigger.
  • Activate at / Deactivate at: Set scheduling times.

Click Save & Close to store the trigger.

Conclusion

You have installed and configured Mautic on an Ubuntu 24.04 server with the LEMP stack, and explored core features like Contacts, Emails, Landing Pages, Campaigns, and Points. Mautic provides a powerful open-source solution for marketing automation, giving you full control over campaigns and customer engagement. With regular updates and an active user community, it is an excellent option for scalable and privacy-conscious marketing.

Source: vultr.com

Create a Free Account

Register now and get access to our Cloud Services.

Posts you might be interested in: