Search

Mautic Installation on VPS (Guide)

Mautic:

Mautic provides free and open-source marketing automation software available to everyone. it is totally free to use and they provide continual updates to make it even better.


Watch the video below to know what it is capable of. Also, check their official site here

https://www.mautic.org



A self-hosted email marketing system:


As we know any email marketing system has two parts:

  • SMTP Server (The sender/receiver): This is a server that is specifically configured to send and receive emails on the internet.

  • The Management Application: where you can configure and connect your SMTP server to send and receive emails and manage your customers (Email Lists).We can also create Email Campaigns, Monitor and analyze results, Manage your delivery servers, etc.

Here we are going to use a VPS machine to install mailwizz application so that it'll be on cloud and accessible on any device. another thing is a SMTP server we already discussed how to set up a FREE SMTP server using postal so to use that server or any other SMTP server such as Amazon SES, Mailgun, Sendgrid, etc. We need an email marketing software tool in our case it is Mailwizz.


Requirements for Mautic installation.

  1. Domain name: will point to our VPS and access out management on ease.

  2. Server or a VPS server: On which we will install our Mailwizz software.

How to get your own domain name:

There are many domain registrars out there where you can buy a domain such as godaddy, namecheap, googledomain, etc. Getting domain names is easy and very cheap nowadays. I recommend buying .com, .org, .net domains as they are considered as standard. If you already own a domain then you can skip this part and continue the next step.


How to get your own VPS:

We need a VPS that is a virtual server on the cloud where we will install our Mailwizz software. Getting a VPS is as easy as getting a domain name. Some of the trusted and famous hosting service providers are Digital ocean and Contabo, Both are cheap and easy to configure.


As a start, you can Ubuntu 16/18 x64 as your OS and a 1-2 core CPU/ 2-4GB of RAM to run the software smoothly on your VPS. And later you can resize it as per the need.


Pointing domain name to VPS:

Once you get your domain to go to your domain name registrar and create a subdomain record and point it to your VPS IP address. in my case, I'll be creating wiz.primeclick.net and point it to my own IP address.


Now once you got a VPS and a domain pointing to it we can proceed with the installation process just follow each step given below and use the commands as it is.


Connect to your server, using an SSH client like putty or bitvise. (Both are free of cost software)


After installing putty put your server IP address as shown in image above and click on OPEN after that you'll get connected to your VPS server via a terminal there it'll ask you for username and password of your VPS login there and now you're ready to fire some commands on it.


Step 1: Install Apache2 Web Server on Ubuntu :


To install Apache Web server just run below 2 commands on terminal

sudo apt update
sudo apt install apache2

Just wait a few seconds for the installation to complete, and after that run the following commands to test and enable the Apache service.

sudo systemctl restart apache2.service
sudo systemctl enable apache2.service

To test if the apache is installed properly and running properly. open any browser and in URL bar enter your VPS IP address (http://XXX.XXX.XXX.XXX) and hit enter


It'll redirect you to this default apache page and you're ready to go next.



Step 2: Installation of MariaDB (MySQL) Database Server;


Any Php script will require a database to store data here in our case we will use the MariaDB database server to store our Mailwizz system data.


To install MariaDB run the command below:


For Ubuntu 16 LTS:

sudo apt-get install software-properties-common gnupg-curl
sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo add-apt-repository 'deb [arch=amd64,arm64,i386,ppc64el] http://mirrors.piconets.webwerks.in/mariadb-mirror/repo/10.5/ubuntu xenial main'
sudo apt update
sudo apt-get install mariadb-server

For Ubuntu 18 LTS:

sudo apt-get install software-properties-common
sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://mirrors.piconets.webwerks.in/mariadb-mirror/repo/10.5/ubuntu bionic main'
sudo apt update
sudo apt-get install mariadb-server 

Below are some handy commands to start, stop, and enable the MariaDB server. Run the below commands now


For Ubuntu 16.04 LTS

sudo systemctl stop mysql.service
sudo systemctl start mysql.service
sudo systemctl enable mysql.service

For Ubuntu 18.04 and 18.10 LTS

sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

Now, to secure the MariaDB server by a root password and disabling remote root access run below command.

sudo mysql_secure_installation

It'll prompt some questions, answer them below by following the guide

  • Enter current password for root (enter for none): (Just press the Enter)

  • Set a root password? [Y/n]: Y

  • New password: (Enter your new password)

  • Re-enter new password: (Repeat your new password)

  • Remove anonymous users? [Y/n]: Y

  • Disallow root login remotely? [Y/n]: Y

  • Remove test database and access to it? [Y/n]:  Y

  • Reload privilege tables now? [Y/n]:  Y

Restart the Mariadb

Restart MariaDB Mysql service

To test if MariaDB is installed, Use the below commands to log in to MariaDB server

sudo mysql -u root -p

Then type the password you created earlier for database, After that, a welcome message will show and you are now inside MariaDB as shown below




Step 3: Installation of PHP and Other Components


Mailwizz is developed using PHP so it'll require PHP 7.0 + to run it. I'll be using 7.1 you can use any version just by replacing mentioning the version name like 7.x and so on.

Now fire below commands

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php

Next, run the commands below to install PHP 7.1 and related components.

(Below is a single line command so copy all and paste it)

sudo apt install php7.1 libapache2-mod-php7.1 php7.1-common php7.1-gmp php7.1-curl php7.1-intl php7.1-mbstring php7.1-xmlrpc php7.1-mysql php7.1-bcmath php7.1-gd php7.1-xml php7.1-cli php7.1-zip php7.1-imap

Wait for some time to finish the installation.

Edit php.ini file:

We will use WinSCP to connect our VPS and browse to locate the config file. just download the application. It is free and small in size also very easy to use.

Next, Open WinSCP, and Connect to your VPS using the root user credentials. and go to: /etc/php/7.X/apache2/ Directory. Then open the “php.ini” file.

Now make changes in the file as mentioned below:

file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 256M //You can increase this if you server can handle
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = America/NewYork //Set you Time Zone here

Now save the file and restart the apache server by using below command;


sudo systemctl restart apache2.service 

Step 4: Creating Mautic Database:


Now we need to create a database and connect it to mailwizz so that it'll be used to store mailwizz data such as email lists, email templates, etc.


To login to the MariaDB MySql database server, run the commands below

sudo mysql -u root -p

Now create a database called Mautic

CREATE DATABASE mautic;

Create a database user called Mautic and give that user a password

CREATE USER 'mautic'@'localhost' IDENTIFIED BY 'Enter_Password_Here';

Now grant the user full access to the database.

(below is a single line command so copy all and paste it)

GRANT ALL ON mautic.* TO 'mautic'@'localhost' IDENTIFIED BY 'Enter_password_here' WITH GRANT OPTION;

Now, save your changes and exit.

FLUSH PRIVILEGES;
EXIT;

Step 5: Downloading and installing Mautic:


To get Mautic latest release version you need to use Github repository… Install Composer, Curl, and other dependencies by using the following commands:


sudo apt install curl git

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

Wait for the installation to complete and change the directory to “/var/www/html”

cd /var/www/html

Now Download Mautic package:

sudo git clone https://github.com/mautic/mautic.git

Installation

cd /var/www/html/mautic
sudo composer install

Set file permissions

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


Mautic installation is done! now we need to configure it so that we access it from our domain name.


Step 6: Configure Apache2 Web Server for Mautic:


navigate to this directory using WinSCP: /etc/apache2/sites-available/


Now create an empty file there and name it as "mautic.conf".



Now open your mautic.conf file and paste the below-given code in it and save it.

(Make sure to replace your domain in my case it's mautic.primeclick.net)

<VirtualHost *:80>
     ServerAdmin admin@mautic.primeclick.net
     DocumentRoot /var/www/html/mautic
     ServerName mautic.primeclick.net
     ServerAlias mautic.primeclick.net

     <Directory /var/www/html/mautic/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

save and close the file and run below commands on putty

sudo a2ensite mautic.conf
sudo a2enmod rewrite
sudo systemctl restart apache2.service 

Step 7: Configuring Mautic:


Now open your browser and hit URL as http://mautic.yourdomain.com in my case it is mautic.primeclick.net


you'll see below windows


Click next and continue the setup by filling all the necessary detail like database name and login credentials and complete the setup.



Step 7: Setting up Cron Jobs (VERY IMPORTANT)


Cron jobs setup is the most important part here. They are simply scheduled tasks that run automatically as configured. So we schedule campaigns in Mailwizz to run them on a specific time we need to set up cron jobs.


Now just copy all the cron jobs given below and paste it in crontab file


 #Segments Every 2 Minutes
*/2 * * * * root /usr/bin/php /var/www/html/mautic/bin/console
mautic:segments:update
*/3 * * * * root /usr/bin/php /var/www/html/mautic/bin/console mautic:import

#Campaigns (Every 1 Minute)
* * * * * root /usr/bin/php /var/www/html/mautic/bin/console mautic:campaigns:update
* * * * * root /usr/bin/php /var/www/html/mautic/bin/console
mautic:campaigns:trigger
* * * * * root /usr/bin/php /var/www/html/mautic/bin/console mautic:messages:send

#Process Email Queue Every 5 Minutes
*/5 * * * * root /usr/bin/php /var/www/html/mautic/bin/console mautic:emails:send
#Fetch and Process Monitored Email Every 10 Minutes
*/10 * * * * root /usr/bin/php /var/www/html/mautic/bin/console mautic:email:fetch

#Process Email Queue Every 5 Minutes
*/5 * * * * root /usr/bin/php /var/www/html/mautic/bin/console mautic:emails:send

#Fetch and Process Monitored Email Every 10 Minutes
*/10 * * * * root /usr/bin/php /var/www/html/mautic/bin/console mautic:email:fetch

Open WinSCP, and navigate to “/etc” directory you will find the “crontab” file. Edit it, and paste the jobs inside, then save.



Now save and close the file and the configuration is done.


That's it !! Mautic is ready for use!


Optional Step: Installing Free SSL Certificate using certbot:

just fire below commands as it is to install SSL

sudo add-apt-repository ppa:certbot/certbot 
sudo apt-get update 
 sudo apt install python-certbot-apache
sudo certbot --apache -d your_domain

ex: sudo certbot --apache -d mautic.primeclick.net


Great! now everything is set up perfectly and ready to use. if you face any problem let me know in the comments below I'll reach you as soon as possible.

22 views

Copyright @ 2020 PrimeClick