How To Install Mautic on Ubuntu 24.04 LTS
How To Install Mautic on Ubuntu 24.04
Mautic is a powerful open-source marketing automation tool that enables businesses to manage their marketing campaigns effectively. Installing Mautic on Ubuntu 24.04 can enhance your email marketing efforts, allowing you to create personalized campaigns, track user engagement, and analyze data seamlessly. This guide provides a comprehensive step-by-step tutorial on how to install Mautic on Ubuntu 24.04, ensuring you have all the necessary tools and configurations for a successful setup.
Prerequisites
Before diving into the installation process, ensure your system meets the following prerequisites:
- System Requirements:
- CPU: 1 GHz or higher
- RAM: Minimum 2 GB (4 GB recommended)
- Disk Space: At least 1 GB of free space
- Software Requirements:
- Operating System: Ubuntu 24.04
- Web Server: Nginx or Apache
- Database: MariaDB or MySQL
- PHP: PHP 8.1 or higher with required extensions
Step-by-Step Installation Guide
Step 1: Update Your System
The first step is to ensure your system is up-to-date. Open your terminal and run the following commands:
sudo apt update && sudo apt upgrade -y
This command updates the package list and upgrades installed packages to their latest versions, ensuring compatibility with Mautic.
Step 2: Install Nginx or Apache
You can choose either Nginx or Apache as your web server. Here’s how to install both:
- Nginx Installation:
sudo apt install nginx -y
Start and enable the Nginx service:
sudo systemctl start nginx sudo systemctl enable nginx
- Apache Installation:
sudo apt install apache2 -y
Start and enable the Apache service:
sudo systemctl start apache2 sudo systemctl enable apache2
You can verify the installation by navigating to your server’s IP address in a web browser. You should see the default web server page.
Step 3: Install PHP and Required Extensions
Mautic requires PHP along with several extensions for optimal performance. Install PHP and the necessary extensions using the following command:
sudo apt install php8.1 php8.1-{mbstring,xml,mysql,curl,gd,intl} -y
This command installs PHP 8.1 along with essential extensions like mbstring for multibyte string handling, xml for XML parsing, mysql for database connections, curl for URL requests, gd for image processing, and intl for internationalization support.
Step 4: Install MariaDB
Mautic requires a database to store its data. MariaDB is a popular choice due to its performance and compatibility with MySQL. Install MariaDB using the following command:
sudo apt install mariadb-server -y
After installation, secure your MariaDB installation by running:
sudo mysql_secure_installation
This script will guide you through securing your database by setting a root password and removing anonymous users.
Create a database and user specifically for Mautic with the following commands in the MariaDB shell:
sudo mysql -u root -p
CREATE DATABASE mautic;
CREATE USER 'mauticuser'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON mautic.* TO 'mauticuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 5: Download Mautic
The next step is to download the latest version of Mautic from its official GitHub repository. First, navigate to your web directory:
cd /var/www/
Create a new directory for Mautic and navigate into it:
sudo mkdir mautic
cd mautic
You can download Mautic using wget
as follows:
wget https://github.com/mautic/mautic/releases/download/5.2.0/5.2.0.zip
If you don’t have unzip installed, you can do so with this command:
sudo apt install unzip -y
Now extract the downloaded zip file and set appropriate permissions:
unzip 5.2.0.zip
sudo chown -R www-data:www-data /var/www/mautic/
sudo chmod -R 755 /var/www/mautic/
Step 6: Configure Web Server for Mautic
You need to configure your web server to serve Mautic correctly. Below are configurations for both Nginx and Apache.
- Nginx Configuration:Create a new configuration file for Mautic in Nginx’s sites-available directory:
sudo nano /etc/nginx/sites-available/mautic
Add the following configuration:
server { listen 80; server_name yourdomain.com; # Change this to your domain root /var/www/mautic; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; # Adjust if using different PHP version fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } }
Create a symbolic link to enable this configuration:
sudo ln -s /etc/nginx/sites-available/mautic /etc/nginx/sites-enabled/
Test the Nginx configuration and reload it if there are no errors:
sudo nginx -t sudo systemctl reload nginx
- Apache Configuration:Create a new virtual host file for Mautic in Apache’s sites-available directory:
sudo nano /etc/apache2/sites-available/mautic.conf
Add the following configuration:
<VirtualHost *:80> ServerName yourdomain.com # Change this to your domain DocumentRoot /var/www/mautic <Directory /var/www/mautic> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
You must enable this virtual host configuration and rewrite module before restarting Apache:
sudo a2ensite mautic.conf sudo a2enmod rewrite sudo systemctl restart apache2
Step 7: Complete Web-Based Installation
Your web server is now configured to serve Mautic. Open your web browser and navigate to http://yourdomain.com
(replace with your actual domain). You should see the Mautic installation wizard.
- Select your preferred language.
- The wizard will check for necessary requirements; ensure all dependencies are satisfied.
- You will need to enter database details:
- Database Type: MySQL/MariaDB
- User Name: mauticuser (the user you created)
- Password: yourpassword (the password you set)
- Database Name: mautic (the database you created)
- Create an admin account by filling out the required fields.
- If you want to configure email settings, you can do so now or skip it for later.
Troubleshooting Common Issues
If you encounter issues during installation, consider these troubleshooting tips:
- If you see “403 Forbidden” errors, check file permissions and ownership of the Mautic directory.
- “Database connection failed” errors usually indicate incorrect database credentials or that MariaDB isn’t running.
- If Nginx returns “502 Bad Gateway,” ensure that PHP-FPM is running properly.
- You can check error logs located at:
- Nginx:
/var/log/nginx/error.log
- Mariadb:
/var/log/mysql/error.log
(if applicable)
- Nginx:
Post-Installation Steps
Your Mautic installation is now complete! However, there are some important post-installation steps to consider for optimal performance and security.
Securitizing Your Mautic Installation with SSL
Securing your site with SSL is crucial for protecting user data and improving SEO rankings. You can obtain a free SSL certificate from Let’s Encrypt by running these commands (assuming you’re using Nginx):
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d yourdomain.com # Replace with your domain name
# Follow prompts to obtain SSL certificate
# Set up automatic renewal
echo "0 0 * * * root certbot renew --quiet" | sudo tee -a /etc/crontab > /dev/null
Congratulations! You have successfully installed Mautic. Thanks for using this tutorial for installing Mautic digital marketing tool on Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the official Mautic website.