Mautic cronjob example

8,23,38,52 * * * * www-data php /var/www/html/bin/console mautic:segments:update > /var/log/cron.pipe 2>&1 –env=prod
*/5 * * * * www-data php /var/www/html/bin/console mautic:import > /var/log/cron.pipe 2>&1 –env=prod
5,20,35,50 * * * * www-data php /var/www/html/bin/console mautic:campaigns:rebuild > /var/log/cron.pipe 2>&1 –env=prod
2,17,32,47 * * * * www-data php /var/www/html/bin/console mautic:campaigns:trigger > /var/log/cron.pipe 2>&1 –env=prod
0,15,30,45 * * * * www-data php /var/www/html/bin/console mautic:messages:send > /var/log/cron.pipe 2>&1 –env=prod
0 * * * * www-data php /var/www/html/bin/console mautic:emails:send > /var/log/cron.pipe 2>&1 –env=prod
0,15,30,45 * * * * www-data php /var/www/html/bin/console mautic:email:fetch > /var/log/cron.pipe 2>&1 –env=prod
0,15,30,45 * * * * www-data php /var/www/html/bin/console mautic:social:monitoring > /var/log/cron.pipe 2>&1 –env=prod
0,15,30,45 * * * * www-data php /var/www/html/bin/console mautic:webhooks:process > /var/log/cron.pipe 2>&1 –env=pord
0 * * * * www-data php /var/www/html/bin/console mautic:broadcasts:send > /var/log/cron.pipe 2>&1 –env=prod
* 1 * * * www-data php /var/www/html/bin/console mautic:maintenance:cleanup –days-old=365 > /var/log/cron.pipe 2>&1 –env=prod
0 4 15 * * www-data php /var/www/html/bin/console mautic:iplookup:download > /var/log/cron.pipe 2>&1 –env=prod
*/5 * * * * www-data php /var/www/html/bin/console mautic:reports:scheduler > /var/log/cron.pipe 2>&1 –env=prod
0 5 10 * * www-data php /var/www/html/bin/console mautic:unusedip:delete > /var/log/cron.pipe 2>&1 –env=prod

How to Install Mautic on CentOS 7

From: https://hostpresto.com/community/tutorials/how-to-install-mautic-on-centos-7/

In addition, I modified some commands according to my actual situation. I install mautic with 4.4.5 version.

Mautic is a free and open source marketing automation software. It is written in PHP using the Symfony framework and uses MySQL/MariaDB to store its data. It provides many out of the box tools for marketing automation such as Social Media Marketing which allows you to engage the leads through social media. It also provides Contact management and email marketing tools. It allows you to create valuable forms for campaigns to collect information and generate reports using the data gathered.

In this tutorial, we will learn to install Mautic on CentOS 7.

Requirements

Mautic can be installed on systems with a small amount of RAM. You will also need a minimal installation of CentOS 7 with root access on it. If you are logged in as a non-root user, you can run sudo -i to switch to root user.

Installing Mautic

Before installing any package it is recommended that you update the packages and repository using the following command.

yum -y update

Once you have your system updated, run the following command to install few packages on your server.

Install Mariadb 10.4, view this manual. https://mariadb.org/download/?t=repo-config&d=CentOS+7+%28x86_64%29&v=10.4&r_m=xtom_hk
yum -y install httpd mariadb-server mariadb

The above command will install Apache web server with MariaDB database server. Now you will need to install PHP. Mautic supports both PHP 5.6 and 7.0. In this tutorial, we will learn to install both PHP 5.6 and 7.0. You must install only one version of PHP. The YUM repository contains PHP version 5.4 only, hence we will need to use the Webtatic repository to install a version of PHP 5.6 or 7.0. Run the following commands for installing EPEL repository as EPEL repository is required before we install Webtatic repository.

I install php 7.4

yum -y install epel-releaseyum -y update
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
## Install PHP 7.4 
yum --enablerepo=remi-php74 install php

Now install Webtatic repository using the following commands.

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

To install PHP 5.6 and all the required PHP modules, run the following command.yum -y install php56w php56w-cli php56w-xml php56w-pdo php56w-mcrypt php56w-imap php56w-posix php56w-intl php56w-mysqli php56w-pear php56w-imap php56w-curl php56w-gd

To install PHP 7.4 and all the required PHP modules, run the following command.

yum -y install php-cli php-xml php-pdo php-mcrypt php-imap php-posix php-intl php-mysqli php-pear php-imap php-curl php-gd

Make sure that you are using only one of the PHP versions mentioned above. Once you have PHP installed, you can check the version of PHP using the following command.

php -v

You should get following output.

[root@liptan-pc ~]# php -v
PHP 7.4.33 (cli) (built: Oct 31 2022 10:36:05) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

Once PHP is installed, you will need to configure few thing in php.ini configuration. Open /etc/php.ini using your favorite editor.

vi /etc/php.ini

scroll down to find the following lines.

; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 512M

You can increase the memory_limit to a higher amount so that the processing of PHP can also be done faster. Next find the following line,

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone = 

Change the timezone according to your country. Save the file and exit from the editor.

Now install Composer using the following command. Composer is a dependency manager for PHP.

curl -sS https://getcomposer.org/installer 
mv composer.phar /usr/bin/composer
php /usr/bin/composer

To start the Apache web server and enable it to start at boot time, run the following commands.

systemctl start httpd
systemctl enable httpd

Start MariaDB and enable it to start at boot time using the following commands.

systemctl start mariadb
systemctl enable mariadb

Now run the following command to secure your MariaDB installation.

mysql_secure_installation

It will run a small script which asks you to provide the root password for MariaDB. As we have just installed MariaDB, the root password is not set, just press enter to proceed further. It will ask you if you want to set a root password for your MariaDB installation, choose y and set a strong password for the installation. It will further ask you for removing test databases and anonymous users. Most of the questions are self-explanatory and you should answer yes or y to all the questions.

To create a database we will need to login to MySQL command line first. Run the following command for same.

mysql -u root -p

This will prompt you for the password, provide the root password of MySQL which you have set earlier. Now run the following query to create a new database for your Mautic installation.

CREATE DATABASE mautic;

The above query will create a database named mautic. For the database, you can use any name you prefer at the place of mautic. Make sure that you use semicolon at the end of each query as the query always ends with a semicolon. Once the database is created you can create a new user and grant all the permissions to the user for the database. To create a new database user, run the following query.

CREATE USER 'mautic_user'@'localhost' IDENTIFIED BY 'StrongPassword';

The above query will create a user with username mautic_user. You can use any preferred username instead of mautic_user. Replace StrongPassword with a strong password. Now provide the appropriate privileges to your database user over the database you have created. Run the following command.

GRANT ALL PRIVILEGES ON mautic.* TO 'mautic_user'@'localhost';

Now run the following command to immediately apply the changes on the database privileges.

FLUSH PRIVILEGES;

Exit from MySQL prompt using exit command.

As we have all the dependencies ready, you can install Mautic using composer. Run the following command for same.

cd /var/www/
wget https://www.mautic.org/download/latest -O mautic.zip
wget https://github.com/mautic/mautic/releases/download/4.4.5/4.4.5-update.zip

The above command will download the latest version of the application archive in mautic.zip file. Now unzip the file into /var/www/mautic directory using the following command.

unzip mautic.zip -d mautic

If you don’t have unzip installed, you can run yum -y install unzip. Now create a virtual host for your domain or subdomain which will be used to access the Mautic site. Run the following command for same.nano /etc/httpd/conf.d/yourdomain.com.conf Copy and paste the following lines into the file.

<VirtualHost *:80>
    ServerAdmin me@liptanbiswas.com
    ServerName yourdomain.com
    DocumentRoot /var/www/mautic
    <Directory />
        Options FollowSymLinks
        AllowOverride All
    </Directory><All /var/www/mautic>
        Options FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        Allow from All
    </Directory>TransferLog /var/log/httpd/your domain.com_access.log ErrorLog /var/log/httpd/yourdomain.com_error.log </VirtualHost>

In the above configuration, replace yourdomain.com with your domain or subdomain.

Provide the ownership of the files to the Apache web server using the following command.chown -R apache:apache /var/www/mautic

Now restart the Apache web server using the following command.

systemctl restart httpd

Now access the following URL through your web browser.http://yourdomain.com

You will see following web interface of environment check. If you have followed the tutorial correctly, you should see that you have all the requirement satisfied to install Mautic.

HP_NO_IMG/data/uploads/users/e840080c-7322-4497-85c0-150182bd4c02/1112193432.png” alt=”” />

Click on Next Step button to proceed further. In this interface, you will need to provide the database credentials. Choose MySQL PDO as database driver. Don’t change the value of database host and port. Provide the name of the database with database username and password. Choose No for backup existing tables.

HP_NO_IMG/data/uploads/users/e840080c-7322-4497-85c0-150182bd4c02/726148226.png” alt=”” />

Click on Next Step button to proceed further. If the database credentials are correct, the installer will write the tables into the database. In next step of installation, you will need to create an administrative account.

HP_NO_IMG/data/uploads/users/e840080c-7322-4497-85c0-150182bd4c02/1203427402.png” alt=”” />

Provide the administrator details and click Next Step to proceed further. In the last step, you will need to configure the email.

HP_NO_IMG/data/uploads/users/e840080c-7322-4497-85c0-150182bd4c02/1714184244.png” alt=”” />

Choose the name and email who will send the outgoing emails. For email handling, you can choose to send immediately. Now choose the mailer transport application. You can choose PHP Mail, if you don’t have an SMTP server. The emails will be sent using phpmail() function. Which is not recommended as the emails will likely go to spam folder. If you have SMTP server, you can provide the server details. You can also choose the many third party email agent for sending emails.

Once done, click on Next Step button to proceed further. The installation of Mautic is now finished, you can click on Proceed to Mautic to go to Mautic Dashboard after logging in.

HP_NO_IMG/data/uploads/users/e840080c-7322-4497-85c0-150182bd4c02/923864607.png” alt=”” />

Conclusion

In this tutorial, we have learned how to install Mautic Marketing Automation Software on CentOS 7. You can now deploy the application on your server to manage the marketing of your organization.