AlmaLinuxRHEL Based

How To Install Mautic on AlmaLinux 9

Install Mautic on AlmaLinux 9

In today’s digital marketing landscape, having a robust marketing automation platform is essential for businesses looking to streamline their marketing efforts. Mautic stands out as a powerful open-source alternative to costly proprietary solutions, offering features like email marketing, lead management, campaign automation, and detailed analytics. When paired with AlmaLinux 9, a stable and reliable RHEL fork, you get a cost-effective and high-performance marketing automation setup.

This comprehensive guide will walk you through the entire process of installing Mautic on AlmaLinux 9, from preparing your server environment to post-installation configuration and troubleshooting. By the end, you’ll have a fully functional Mautic installation ready to power your marketing campaigns.

Prerequisites

Before diving into the installation process, ensure your system meets the following requirements:

System Requirements:

  • A server with AlmaLinux 9 installed
  • Minimum 10GB of disk space (15GB+ recommended)
  • At least 4GB RAM (8GB+ recommended for optimal performance)
  • A registered domain name pointing to your server
  • Root or sudo access to your server

Knowledge Requirements:

  • Basic Linux command line skills
  • Fundamental understanding of web servers and databases
  • Basic networking concepts

Installation time will vary depending on your system specifications and internet connection speed, but typically takes 30-45 minutes to complete.

Installing AlmaLinux 9

If you already have AlmaLinux 9 installed, you can skip this section. Otherwise, follow these steps to install AlmaLinux 9.

Downloading AlmaLinux 9 ISO

  1. Visit the official AlmaLinux website and download the appropriate ISO file.
  2. AlmaLinux offers several ISO types:
    • Boot ISO: For minimal network-based installations
    • Minimal ISO: For basic server setups
    • DVD ISO: For complete installation options
  3. Download the ISO that best suits your needs using a direct download or torrent.

Creating Bootable Media

  1. For USB installation:
    sudo dd if=AlmaLinux-9.0-x86_64-dvd.iso of=/dev/sdX bs=8M status=progress

    (Replace /dev/sdX with your actual USB device path)

  2. For virtual environments, simply mount the ISO file as a virtual DVD drive.

Installation Process

  1. Boot your system from the installation media.
  2. Select “Install AlmaLinux 9” from the boot menu.
  3. Choose your language and keyboard layout.
  4. Configure installation destination:
    • Select your storage device
    • Choose automatic partitioning or customize it
  5. Configure network and hostname:
    Hostname: mautic.yourdomain.com
  6. Create a root password and admin user.
  7. Complete the installation and reboot.
  8. After reboot, log in with your credentials.

Preparing the Server Environment

With AlmaLinux 9 installed, we need to prepare the environment for Mautic installation by setting up the necessary components.

System Updates

First, ensure your system is up to date:

sudo dnf update -y

Installing Required Packages

Mautic 5.x requires PHP 8.1 or newer, MariaDB/MySQL, and a web server like Apache. Let’s install these components.

  1. Install EPEL and Remi Repositories:
    sudo dnf install epel-release -y
    sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm -y
  2. Install Apache Web Server:
    sudo dnf install httpd -y
    sudo systemctl enable httpd
    sudo systemctl start httpd
  3. Install PHP 8.2 and Extensions:
    sudo dnf module reset php -y
    sudo dnf module enable php:remi-8.2 -y
    sudo dnf install php php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mbstring php-curl php-xml php-pear php-bcmath php-json php-intl php-opcache -y
  4. Install MariaDB:
    sudo dnf install mariadb-server -y
    sudo systemctl enable mariadb
    sudo systemctl start mariadb
  5. Install Additional Utilities:
    sudo dnf install unzip wget git -y

These packages provide the foundation for running Mautic efficiently on AlmaLinux 9.

Firewall Configuration

Configure the firewall to allow HTTP, HTTPS, and SSH connections:

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --reload

This ensures your Mautic installation will be accessible via web browsers while maintaining basic security.

Database Setup

A properly configured database is critical for Mautic’s performance and security.

Installing and Securing MariaDB

If you haven’t already secured your MariaDB installation:

sudo mysql_secure_installation

Follow the prompts to:

  • Set a root password
  • Remove anonymous users
  • Disallow root login remotely
  • Remove the test database
  • Reload privileges

Creating Mautic Database

  1. Log in to MariaDB:
    sudo mysql -u root -p
  2. Create a database and user for Mautic:
    CREATE DATABASE mautic CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
    CREATE USER 'mauticuser'@'localhost' IDENTIFIED BY 'secure_password';
    GRANT ALL PRIVILEGES ON mautic.* TO 'mauticuser'@'localhost';
    FLUSH PRIVILEGES;
    EXIT;

Replace ‘secure_password’ with a strong password. This configuration ensures proper character set support for international content.

Optimizing MariaDB for Mautic

For optimal performance, edit the MariaDB configuration:

sudo nano /etc/my.cnf.d/server.cnf

Add these settings under the [mysqld] section:

innodb_buffer_pool_size = 1G
max_allowed_packet = 64M
join_buffer_size = 2M

Save and restart MariaDB:

sudo systemctl restart mariadb

These settings improve performance for Mautic’s database operations with large datasets.

Web Server Configuration

Apache needs to be properly configured to serve Mautic efficiently and securely.

Apache Setup and Optimization

  1. Create a virtual host configuration for Mautic:
    sudo nano /etc/httpd/conf.d/mautic.conf
  2. Add the following configuration:
    <VirtualHost *:80>
        ServerAdmin webmaster@yourdomain.com
        DocumentRoot /var/www/html/mautic
        ServerName mautic.yourdomain.com
    
        <Directory /var/www/html/mautic>
            Options -Indexes +FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>
    
        ErrorLog /var/log/httpd/mautic_error.log
        CustomLog /var/log/httpd/mautic_access.log combined
    </VirtualHost>
  3. Save and check the configuration:
    sudo apachectl configtest
  4. If the test passes, restart Apache:
    sudo systemctl restart httpd

HTTPS Setup with Let’s Encrypt

Secure your Mautic installation with HTTPS:

  1. Install Certbot:
    sudo dnf install certbot python3-certbot-apache -y
  2. Obtain and configure SSL certificate:
    sudo certbot --apache -d mautic.yourdomain.com
  3. Follow the prompts to complete the certificate installation and configure automatic renewal.

This setup ensures secure communications between users and your Mautic installation.

PHP Configuration

Optimize PHP for Mautic:

  1. Edit the PHP configuration:
    sudo nano /etc/php.ini
  2. Update the following values:
    memory_limit = 512M
    upload_max_filesize = 100M
    post_max_size = 100M
    max_execution_time = 300
    max_input_time = 300
  3. Save and restart PHP-FPM:
    sudo systemctl restart php-fpm

These settings ensure PHP can handle Mautic’s resource requirements efficiently.

Installing Mautic

Now let’s install Mautic itself.

Downloading Mautic

  1. Change to the web directory:
    cd /var/www/html
  2. Download the latest Mautic release:
    sudo wget https://github.com/mautic/mautic/releases/download/6.0.1/6.0.1.zip
  3. Extract the files:
    sudo unzip 6.0.1.zip
    sudo mv mautic-6.0.1 mautic
  4. Remove the zip file:
    sudo rm 6.0.1.zip

Setting Correct File Permissions

Proper file permissions are essential for security and functionality:

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

This ensures the web server can read and write to the necessary files while maintaining security.

Running the Mautic Installer

With all components in place, you can now run the Mautic web installer.

Accessing the Web Installer

  1. Open your web browser and navigate to your domain (https://mautic.yourdomain.com).
  2. The Mautic installer will automatically start and check your system requirements.
  3. If any requirements are not met, you’ll need to address them before continuing.

Database Configuration

  1. On the database setup screen, enter your database details:
    • Database Driver: MySQL PDO
    • Database Host: localhost
    • Database Name: mautic
    • Database User: mauticuser
    • Database Password: your_secure_password
    • Database Port: 3306 (default)
  2. Choose whether to backup existing tables (not necessary for new installations).
  3. Click “Next Step” to proceed.

Creating Admin Account

  1. Create your administrator account:
    • Username: Choose a username
    • Password: Create a strong password
    • Email: Enter your email address
    • First Name: Enter your first name
    • Last Name: Enter your last name
  2. Click “Next Step” to continue.

Initial Configuration

  1. Configure your email settings:
    • From Name: Your organization name
    • From Email: A valid email address
    • Email Transport: Choose based on your email setup
  2. Set your site URL and locale settings.
  3. Complete the installation process.

You should now see the Mautic login screen where you can access your new installation.

Post-Installation Configuration

After installing Mautic, several additional configurations are necessary for optimal performance.

Setting Up Cron Jobs

Mautic requires scheduled tasks to function properly:

sudo crontab -e

Add these cron jobs:

# Mautic cron jobs
10,40 * * * * php /var/www/html/mautic/bin/console mautic:segments:update
15,45 * * * * php /var/www/html/mautic/bin/console mautic:campaigns:update
20,50 * * * * php /var/www/html/mautic/bin/console mautic:campaigns:trigger
*/5 * * * * php /var/www/html/mautic/bin/console mautic:emails:send
*/5 * * * * php /var/www/html/mautic/bin/console mautic:import:process

These jobs ensure that segments are updated, campaigns are processed, and emails are sent automatically.

Email Configuration

Configure email sending for your Mautic installation:

  1. Log in to Mautic admin panel
  2. Navigate to Configuration → Email Settings
  3. Configure your preferred mail transport:
    • SMTP for reliable delivery
    • Mail for simple setups
    • API-based services like SendGrid or Mailgun
  4. Test email delivery to ensure proper configuration

Proper email configuration is essential for marketing campaigns and system notifications.

Performance Optimization

To improve Mautic’s performance:

  1. Enable cache:
    php /var/www/html/mautic/bin/console cache:clear
    php /var/www/html/mautic/bin/console mautic:assets:generate
  2. Optimize database queries:
    php /var/www/html/mautic/bin/console doctrine:schema:update --dump-sql
  3. Consider implementing a Redis cache for larger installations:
    sudo dnf install redis -y
    sudo systemctl enable redis
    sudo systemctl start redis

These optimizations will help maintain good performance as your contact database grows.

Troubleshooting Common Installation Issues

Even with careful installation, issues may arise. Here are solutions to common problems.

Permission Problems

If you encounter permission errors:

sudo find /var/www/html/mautic -type d -exec chmod 755 {} \;
sudo find /var/www/html/mautic -type f -exec chmod 644 {} \;
sudo chown -R apache:apache /var/www/html/mautic

This ensures proper ownership and permissions for all Mautic files.

Database Connection Issues

For database connection problems:

  1. Verify your database credentials in /var/www/html/mautic/app/config/local.php
  2. Test the connection manually:
    mysql -u mauticuser -p -h localhost mautic
  3. Check MariaDB status:
    sudo systemctl status mariadb

Database connection issues are often related to incorrect credentials or database server problems.

Web Server Configuration Problems

For Apache configuration issues:

  1. Check Apache error logs:
    sudo tail -f /var/log/httpd/error_log
  2. Verify that mod_rewrite is enabled:
    sudo apachectl -M | grep rewrite
  3. Test Apache configuration:
    sudo apachectl configtest

Most web server issues are related to incorrect virtual host configuration or missing Apache modules.

Mautic-Specific Errors

For 500 Internal Server errors or other Mautic-specific issues:

  1. Check Mautic logs:
    tail -f /var/www/html/mautic/var/logs/mautic_prod.log
  2. Clear Mautic cache:
    rm -rf /var/www/html/mautic/var/cache/*
  3. Update database schema:
    php /var/www/html/mautic/bin/console doctrine:schema:update --force

These steps resolve many common Mautic errors related to caching and database structure.

Security Hardening

Protecting your Mautic installation is crucial for data security and compliance.

Basic Security Measures

  1. Implement strong file permissions:
    sudo find /var/www/html/mautic -type f -exec chmod 644 {} \;
    sudo find /var/www/html/mautic -type d -exec chmod 755 {} \;
    sudo chmod -R 775 /var/www/html/mautic/var/cache
    sudo chmod -R 775 /var/www/html/mautic/var/logs
  2. Protect sensitive directories:
    sudo nano /var/www/html/mautic/.htaccess

    Add:

    # Deny access to sensitive directories
    RedirectMatch 403 ^/app/
    RedirectMatch 403 ^/vendor/
  3. Restrict admin access using IP-based rules in your virtual host configuration.

Regular Updates Process

Keep your system secure with regular updates:

  1. Create a backup before updating:
    sudo cp -r /var/www/html/mautic /var/www/html/mautic_backup
    mysqldump -u mauticuser -p mautic > mautic_backup.sql
  2. Update AlmaLinux:
    sudo dnf update -y
  3. Update Mautic following the official documentation for your specific version.

Regular updates ensure you have the latest security patches and features.

Alternative Installation Methods

Besides the manual installation method described above, there are other options for installing Mautic.

Using Pre-configured Images

Several cloud providers offer pre-configured Mautic images:

  1. AWS Marketplace has Mautic images from providers like Elyxia Global
  2. Digital Ocean offers one-click Mautic applications
  3. Bitnami provides Mautic stacks for various cloud platforms

These options simplify deployment but may limit customization options.

Command Line Installation

For advanced users, Mautic can be installed via command line:

php /var/www/html/mautic/bin/console mautic:install \
  --db_driver="pdo_mysql" \
  --db_host="localhost" \
  --db_port="3306" \
  --db_name="mautic" \
  --db_user="mauticuser" \
  --db_password="secure_password" \
  --db_backup_tables="false" \
  --admin_email="admin@example.com" \
  --admin_password="secure_admin_password" \
  --mailer_from_name="Your Company" \
  --mailer_from_email="marketing@example.com"

This approach is ideal for automated deployments and scripted installations.

Congratulations! You have successfully installed Mautic. Thanks for using this tutorial for installing Mautic digital marketing tool on AlmaLinux 9 system. For additional help or useful information, we recommend you check the official Mautic website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button