Ad

How to install Mautic on Centos 7

Posted smtp php mysql centos mautic

Introduction

Mautic is a very popular email marketing and lead management software that can be used to create customized email templates and email campaigns. Here are the detailed steps you need to follow to install Mautic on your Linux server - Centos 7.

Prerequisites

  1. PHP 5.6.19 + (Magic Quotes GPC off)
  2. MySQL 5.5.3 + (InnoDB support required)
  3. Apache / Nginx
  4. An SMTP provider like Pepipost\

Ad Image

Installation

Step 1: Enter into the root directory of your remote server

$ cd var/www/html/

Step 2: Create a new directory named Mautic

$ sudo mkdir mautic
$ cd mautic

Step 3: Download the Mautic production file package

To download Mautic at your local machine click here

Fill your credentials and click on the download button

The downloaded file would be named something like this 2.15.3.zip

Step 4: Copy the zip file to the remote server

Enter the following commands in your local machine download file location

$ scp -r 2.15.3.zip root@<your-domain-name/ip-address>:/var/www/html/mautic/mautic.zip

Note:- By any chance you don't have access to copy files to your server directory you can use FTP to upload the zip file, or you can use the git repo to clone it to your server directory, but you have to take some additional steps to get it up and running. Check this link for Mautic git repo.

Step 5: Unzip the file contents

$ sudo unzip mautic.zip

If you don't have unzip installed you can install it by using

$ sudo yum install unzip

Step 6: Delete the zip file

$ sudo rm -rf mautic.zip

Step 7: Install php-fpm and dependencies

$ sudo yum -y install php7-fpm php-mbstring php-xml php-mysql php-common php-gd php-json php-cli php-curl php-zip php-xml php-mcrypt php-imap php-intl php-process

Step 8: Setting up MySQL

  • Download the rpm file
$ wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
  • Set the installation package
$ sudo rpm -ivh mysql57-community-release-el7-9.noarch.rpm
  • Install MySQL server
$ sudo yum install mysql-server
  • Start MySQL
$ sudo systemctl start mysqld
  • Set MySQL root password

- After the installation a temporary password will be generated in the mysqld.log file you can access this password by the following command

$ sudo grep 'temporary password' /var/log/mysqld.log

- Now you will get a message something like this

[Note] A temporary password is generated for root@localhost: ,b*-rkuIR4Zas

- Copy this password for the next step

- Enter this command

$ sudo mysql_secure_installation

- This will prompt you to enter the root password you can enter the copied password you've got in the previous step

- After entering the password you will be prompted to enter a new MySQL password.

- Enter a new 12 character password with uppercase lowercase letters, numerical and a special character

- You will now be prompted with multiple questions on how to set up the MySQL installation. You can say yes to all except if asked to change the password again.

  • Login to MySQL with your newly set password.
  • Create Mautic database and add User
mysql > create database mautic;

mysql > CREATE USER 'mauticuser'@'localhost' IDENTIFIED BY 'password';

mysql > GRANT ALL PRIVILEGES ON * . * TO 'mauticuser'@'localhost';

mysql > FLUSH PRIVILEGES;

mysql > exit;

Step 9: Setting up Http Server

(You can install Nginx or Apache server according to your needs)

- Nginx:

  • For installing Nginx you can follow these steps
$ sudo yum install nginx
$ sudo systemctl start nginx
$ sudo systemctl enable nginx
  • You need to make the following changes to nginx.conf file
$ vim /etc/nginx/nginx.conf
server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  <Your domain name>;
        root         /var/www/html/mautic;

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

        location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        }
    }

Now depending upon your php-fpm setup you either need to add

fastcgi_pass 127.0.0.1:9000;

Or

fastcgi_pass unix:/var/run/php5-fpm.sock;

Note: If you are unclear on which value has to be set, you can check this in www.conf file.

$ vim /etc/php-fpm.d/www.conf

Search for the listen parameter.

- Apache:

  • For installing Apache you can follow these steps
$ sudo yum install httpd
$ sudo systemctl start httpd
$ sudo systemctl enable httpd
  • You need to make the following changes to httpd.conf file
$ vim /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
DocumentRoot /var/www/html/mautic
<Directory />
        Options FollowSymLinks
        AllowOverride All
    </Directory>
    <Directory /var/www/mautic>
        Options FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        Allow from All
    </Directory>
</VirtualHost>

After this you will be opening http://<your-domain-address>/ to open Mautic installation panel

Step 10: Setting folder permissions

You may get this error if some folder permissions are not set

Image

This error might exist because your Mautic folder user group is not the same as your running php-fpm instance.

Depending upon your user group you can set the following permissions.

Run the following commands to set permissions for Mautic installation

If your php-fpm user group is www-data

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

If it is nginx you have to set permissions like this

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

And for user group apache add

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

You can check user group of php-fpm file by using

$ ps -ef | grep fpm

Or you can check php-fpm config file by

$ vim /etc/php-fpm.d/www.conf

In this file check the user option

Set the Mautic directory permission

$ sudo chmod -R 755 /var/www/html/mautic/

Note: Also make sure that your PHP session path folder should also be added to the user group

$ vim /etc/php-fpm.d/www.conf

In this file check the php_value[session.save_path] attribute

Even by following the above steps you are still having issues use the following commands

sudo chcon -t httpd_sys_rw_content_t /var/www/html/mautic/app/logs -R
sudo chcon -t httpd_sys_rw_content_t /var/www/html/mautic/app/cache -R
sudo chcon -t httpd_sys_rw_content_t /var/www/html/mautic/app/config -R

Make sure you have all the PHP dependencies installed

Now you can go back to the browser and refresh the window and hopefully you have solved this error. If you are still getting the error screen you can try to debug using the Nginx error logs at.

/var/log/nginx/error.log

Setup

If you haven’t yet set up Mautic, you will be redirected to the installation panel.

If all the dependencies are matched for the installation of Mautic you will be shown a Ready to install prompt on the screen, Else the dependencies that are not satisfied will be listed on the panel.

If there are any minor bugs that need to be fixed they will be listed in the recommendations section. You can opt for fixing these recommendations.

Step1: Resolving remaining dependencies

After you have fixed the stated dependencies click on [Next Step] button.

Image

Step 2: Set your database credentials

  • Keep the Database Driver to preset MYSQL PDO
  • Enter database name mautic, database username mauticuser and password that you have set.
  • No need to set Backup existing tables Option if this is your first installation
  • Click on next

Image

Click on the Next Step button.

Note:- If you are having a problem with the blank Database Driver dropdown please make sure that you have all PHP dependencies installed you might haven't installed mysqlmd php dependency.

Step 3: Set Admin user settings

Enter the Admin credentials, these credentials will be used when logging in the Mautic user panel.

The email address you enter will be used for password resets.

Click on the Next Step button.

Before you proceed to the next step you will need our Pepipost SMTP server credentials.

Step 4: Get your Pepipost SMTP credentials

  • Log in with your user credentials on Pepipost application
  • Open SMTP integration panel using this link
  • You will find your SMTP credentials in SMTP Relay tab

Please check the screenshot provided below for reference:

Image

You will use these credentials to set up our SMTP configuration in the next step

Step 5: Set  SMTP configuration settings

Now back at the Mautic installation screen

In [Who should the email be sent as?] section there are two parameters

  1. Your from-name that would be seen on the send email.
  2. Your from-email-id, for example, test@domain.com. The domain name should be a valid and verified domain in order to send emails from the Pepipost mail server.

in [How should email be spooled and delivered?] section you will be setting the following options.

In Email handling,there are two options.

  1. First is Send Immediately: This is recommended if your email list is not too large else it will result in a slowdown.
  2. Second is Queue: This option means that the mail list will be kept in a message pool and are in a wait state until it is executed in a batch by send email cron.

Mailer transport: Select [Other SMTP Server]

Server: smtp.pepipost.com

Port: 25 [or you can set the port to 587 if 25 is blocked at your sever]

Encryption: TLS

Authentication mode: Login

Username: Your_Pepipost_username

Password: Your_Pepipost_password

Click on Next step

After this, you will be redirected to the login panel. Log in with your credentials and with this you will move on to the next step

This is how your dashboard will look

Image

Adding Cron Jobs:

Cronjob is nothing but a scheduler that runs the specified path at a specified interval. Every action and updates done in the Mautic is mostly done by the Cron job running at regular intervals, If they are not set most of the Mautic's functionalities won't work.

For installing Cron jobs use the following command.

$ yum install cronie

Follow these steps to add Mautic Cron jobs.

$ sudo crontab -e

Add the following Crons

*/5 * * * *  php /var/www/html/mautic/app/console mautic:segments:update >> /var/log/crontab.log 2>&1   
 
*/10 * * * *  php /var/www/html/mautic/app/console mautic:campaigns:update >> /var/log/crontab.log 2>&1   
   
*/12 * * * *  php /var/www/html/mautic/app/console mautic:campaigns:trigger >> /var/log/crontab.log 2>&1  

*/15 * * * *  php /var/www/html/mautic/app/console mautic:emails:send >> /var/log/crontab.log 2>&1

Based on the Cron set up your contacts, campaign and emails will be triggered, you might want to change the time interval of all of these Cron jobs based on your requirements.

Note: It is recommended that the Cron job interval doesn't collide with each other so keep the Cron timings unique.

Sending your first test mail

Step 1: Add new contacts

There are two steps for creating new contacts

1. Single contact creation

  • Click on contacts in the navbar
  • Click on New
  • You will be able to view a detailed form in which you can add user credentials, for testing purposes you can add email and username.
  • Click on [Apply]
  • Click [Save & Close]
  • In your contact panel, you will be able to see the newly created contact

Image

2. Bulk Upload email list

  • Create a new CSV file with a list of emails that you want to send your emails to. Refer below image for CSV file reference.

Image

  • Click on contacts in the navbar
  • Click on the dropdown arrow next to prev button
  • Click on import

Image

  • File upload panel will open
  • Click on choose file
  • Select the CSV files of email list and click on upload
  • You can change the limit option when you are uploading a large CSV file, this parameter decides the number of email batches that Mautic will start importing at a time.

Image

  • After this, you will be redirected to the Import panel, where you can select multiple options for the upload.
  • There are two sections in this panel the first one is optional which you can set to customize your import 
  • In the second section, the values will be visible above the dropdown select the appropriate dropdown value according to the value above it, for example, Clients First Name should be assigned to First name dropdown and email id to email as shown in the screenshot below.

Image

  • Now there are two options to import, First is Import in the browser(For small email lists could be in hundreds or a thousand) the import needs the browser window to stay open. It is faster and you will be able to see the progress through a progress bar but is not recommended for a very large email list.
  • The second is import in the background which is recommended for a large import list which could be in the ten thousand or in millions but doesn’t need the browser to be kept open.
  • After the import, the success message would be displayed and you can view the imported contacts.

Step 2: Create a new segment

  • Click on Segments in the navbar
  • There would be no segments created In the segments panel so click on New button
  • Enter segment name and alias (you can leave this empty, it will autogenerate if it is set to blank)

Image

  • Click on the Filters tab
  • Now you will be filtering the email list on email id, So in the dropdown select the email 

Image

  • Set the email filtering conditions based on which particular emails will be grabbed from your email list to your campaign.
  • You can use the filtering in a really flexible way to filter out the emails, for more information on segments please refer this link
  • For this tutorial, you will select [is not empty] option in order to select all emails in the list by setting an email filter to not empty.

Image

  • Click on Apply -> Save & Close
  • Depending upon the Cron set up your segment list will be populated

Step3: Create a new campaign

  • Click on campaigns section in the navbar
  • Click on the New button
  • Enter campaign name and description

Image

  • Click on [Launch campaign builder]
  • In contact source select  [Contact Segments]
  • A popup will open named Contact Source in it select the segment you want to apply and click on add

Image

  • Click on [Apply]->[Save & Close]
  • After this, you will see a square block with the name of the segment on it
  • Click on the grey semicircle and you will be able to see some options as shown in the image

Image

  • Click on the select button inside the Action section and select Send Email from the dropdown which will appear once you click on select.
  • A popup will open named Send Email. 

Image

  • Set the Email name
  • Inside Email to send click on the Create new dropdown
  • A popup will open with a number of email templates that you can use to send the email.
  • For now, you can select the Blank templateoption.
  • Enter some basic credentials like Subject, Internal name.

Image

  • Click on the Advanced tab
  • Enter From-name 
  • Enter From-address as your valid from address is with a valid domain name
  • Enter Reply-to address

Image

  • Click on Builder button to open builder, a new window will open 
  • Create your email body as per your requirements

Image

  • Click on [Apply] -> [Save & Close]
  • Set email type according to your needs

Image

  • Click on add. The panel will close and you will be able to see the email flow in a relational diagram.

Image

  • Click on [Apply] -> [Close Builder]
  • In the Edit Campaign panel set published to Yes
  • Click on [Apply] -> [Save & Close]

This will open the Campaign panel in which all the campaign status is represented in a graphical format in which you can track the emails that are being sent.

With this, your campaign is ready to send emails from your imported segment.

After some time as the Cron runs, you will be able to see the emails being populated in the dashboard.

You can check the progress of your campaign in the campaign panel.

Image

Conclusion

By following the above-mentioned steps you are now ready to send emails through the Mautic platform. You are now able to upload an email list, create an email body, filter the email leads with segments and send emails using the Pepipost SMTP server.