Deploying Mautic: Difference between revisions

From The Opensource Knowledgebase
Jump to navigation Jump to search
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 35: Line 35:
|}
|}
=Before you proceed=
=Before you proceed=
The domain used here is '''networked.com'''. This is used only for demonstration and required dns entries for this domain have already been done to the host file to make the domain and any subdomains reachable on the network. This domain may be owned by someone else and we do not know who it is and we are not linked to them. Wordpress configured for this domain in this howto is not reachable on public IP. If you try networked.com and find any material that may be suitable / unsuitable to you, we are not the owners of the same and we are not responsible for the content.
The domain used here is '''networked.com'''. This is used only for demonstration and required dns entries for this domain have already been done to the host file to make the domain and any subdomains reachable on the network. This domain may be owned by someone else and we do not know who it is and we are not linked to them. Mautic configured for this domain in this howto is not reachable on public IP. If you try networked.com and find any material that may be suitable / unsuitable to you, we are not the owners of the same and we are not responsible for the content.


=Introduction=
=Introduction=
Line 44: Line 44:
=Pre-requisites installation=
=Pre-requisites installation=
* Log into the webserver and run the below commands
* Log into the webserver and run the below commands
<syntaxhighlight lang="bash">
<pre>
ssh kedar@10.1.65.107
ssh kedar@10.1.65.107
sudo apt install apache2 php7.2 php7.2-curl php7.2-gd php7.2-intl php7.2-json php7.2-mbstring php7.2-mysql php7.2-soap php7.2-xml php7.2-zip libapache2-mod-php7.2  
sudo apt install apache2 php7.2 php7.2-curl php7.2-gd php7.2-intl php7.2-json php7.2-mbstring php7.2-mysql php7.2-soap php7.2-xml php7.2-zip libapache2-mod-php7.2  
Line 52: Line 52:
sudo systemctl restart apache2
sudo systemctl restart apache2
sudo systemctl status apache2
sudo systemctl status apache2
</syntaxhighlight>
</pre>
=Database Creation=
=Database Creation=
*Database will be created in a mariadb server which is installed into a container created on the host server (infrabase1). Latest mariadb server has been installed and run the below commands after an ssh into the mariadb server.
*Database will be created in a mariadb server which is installed into a container created on the host server (infrabase1). Latest mariadb server has been installed and run the below commands after an ssh into the mariadb server.
<syntaxhighlight lang="bash">
<pre>
sudo mysql -u root -p
sudo mysql -u root -p
CREATE DATABASE mautic;
CREATE DATABASE mautic;
Line 61: Line 61:
FLUSH PRIVILEGES;
FLUSH PRIVILEGES;
quit;
quit;
</syntaxhighlight>
</pre>
=Create self signed certificates=
=Create self signed certificates=
* Log into the webserver and run the below commands
* Log into the webserver and run the below commands
<syntaxhighlight lang="bash">
<pre>
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/mautic.key -out /etc/ssl/certs/mautic.crt
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/mautic.key -out /etc/ssl/certs/mautic.crt
</syntaxhighlight>
</pre>
* You can use a commercial self signed certificate if you have one or can also use free Lets Encrypt certificate  
* You can use a commercial self signed certificate if you have one or can also use free Lets Encrypt certificate  
=Download Mautic=
=Download Mautic=
Line 72: Line 72:
* Transfer this zip file using sftp or ftp or any other way to the webserver (10.1.65.107) in /home/kedar/ directory
* Transfer this zip file using sftp or ftp or any other way to the webserver (10.1.65.107) in /home/kedar/ directory
* Log into the webserver and run the below commands
* Log into the webserver and run the below commands
<syntaxhighlight lang="bash">
<pre>
cd /var/www/html
cd /var/www/html
sudo mkdir mautic
sudo mkdir mautic
</syntaxhighlight>
</pre>
=Deploy Mautic=
=Deploy Mautic=
<syntaxhighlight lang="bash">
<pre>
cd /home/kedar
cd /home/kedar
unzip 2.16.2.zip
unzip 2.16.2.zip
cd mautic
cd mautic
sudo rsync -avz . /var/www/html/mautic
sudo rsync -avz . /var/www/html/mautic
</syntaxhighlight>
</pre>
* Change the ownership of the mautic folder to apache user
* Change the ownership of the mautic folder to apache user
<syntaxhighlight lang="bash">
<pre>
cd /var/www/html
cd /var/www/html
sudo chown -R www-data:www-data mautic/
sudo chown -R www-data:www-data mautic/
sudo systemctl restart apache2
sudo systemctl restart apache2
</syntaxhighlight>
</pre>
* Create virtual host for the website
* Create virtual host for the website
<syntaxhighlight lang="bash">
<pre>
cd /etc/apache2/sites-available
cd /etc/apache2/sites-available
sudo a2dissite 000-default.conf
sudo a2dissite 000-default.conf
sudo a2dissite default-ssl.conf
sudo a2dissite default-ssl.conf
sudo nano mautic.conf
sudo nano mautic.conf
</syntaxhighlight>
</pre>
* Add the below configuration in the mautic.conf file
* Add the below configuration in the mautic.conf file
<syntaxhighlight lang="apacheconf">
<syntaxhighlight lang="apacheconf">
Line 118: Line 118:
</VirtualHost>
</VirtualHost>
</IfModule>
</IfModule>
</syntaxhighlight>
</pre>
* Enable the site and Restart apache service
* Enable the site and Restart apache service
<syntaxhighlight lang="bash">
<pre>
sudo a2ensite mautic.conf
sudo a2ensite mautic.conf
sudo sysemctl restart apache2
sudo sysemctl restart apache2
</syntaxhighlight>
</pre>
* Using a browser navigate to https://mautic.networked.com
* Using a browser navigate to https://mautic.networked.com
** Answer various questions based on some of the steps we have done above like db name, db user, db server etc.
** Answer various questions based on some of the steps we have done above like db name, db user, db server etc.
Line 132: Line 132:
* Following cronjob should be configured.
* Following cronjob should be configured.
**ssh in to the webserver
**ssh in to the webserver
<syntaxhighlight lang="bash">
<pre>
crontab -e
crontab -e
</syntaxhighlight>
</pre>
*Choose the choice by entering the number against the editor you want to use
*Choose the choice by entering the number against the editor you want to use
*At the end of the file add the below lines. These numbers have been picked up from the mautic documentation website
*At the end of the file add the below lines. These numbers have been picked up from the mautic documentation website
<syntaxhighlight lang="bash">
<pre>
0,15,30,45 * * * * /usr/bin/php /var/www/html/mautic/app/console mautic:segments:update
0,15,30,45 * * * * /usr/bin/php /var/www/html/mautic/app/console mautic:segments:update
5,20,35,50 * * * * /usr/bin/php /var/www/html/mautic/app/console mautic:campaigns:update
5,20,35,50 * * * * /usr/bin/php /var/www/html/mautic/app/console mautic:campaigns:update
10,25,40,55 * * * * /usr/bin/php /var/www/html/mautic/app/console mautic:campaigns:trigger
10,25,40,55 * * * * /usr/bin/php /var/www/html/mautic/app/console mautic:campaigns:trigger
0,15,30,45 * * * * /usr/bin/php /var/www/html/mautic/app/console mautic:emails:send
0,15,30,45 * * * * /usr/bin/php /var/www/html/mautic/app/console mautic:emails:send
</syntaxhighlight>
</pre>
*Save and exit
*Save and exit
*Check the status of the cron if it is running by executing the following command
*Check the status of the cron if it is running by executing the following command
<syntaxhighlight lang="bash">
<pre>
sudo tail -f /var/log/syslog
sudo tail -f /var/log/syslog
</syntaxhighlight>
</pre>


=Conclusion=
=Conclusion=

Latest revision as of 05:35, 9 June 2020

Setup Details
hostname: infrabase1
Network: 10.1.65.0/24
IP Address : 10.1.65.11
Subnet Mask: 255.255.255.0
Gateway: 10.1.65.1
DNS: 8.8.8.8
sudo user: kedar

Container: webserver
Network: 10.1.65.0/24
IP Address : 10.1.65.107
Subnet Mask: 255.255.255.0
Gateway: 10.1.65.1
DNS: 8.8.8.8
sudo user: kedar

Container: db1
Network: 10.1.65.0/24
IP Address : 10.1.65.108
Subnet Mask: 255.255.255.0
Gateway: 10.1.65.1
DNS: 8.8.8.8
sudo user: kedar

User PC Details
PC type: Desktop
OS: Ubuntu Desktop
IP Address: 10.1.65.160

Before you proceed

The domain used here is networked.com. This is used only for demonstration and required dns entries for this domain have already been done to the host file to make the domain and any subdomains reachable on the network. This domain may be owned by someone else and we do not know who it is and we are not linked to them. Mautic configured for this domain in this howto is not reachable on public IP. If you try networked.com and find any material that may be suitable / unsuitable to you, we are not the owners of the same and we are not responsible for the content.

Introduction

  • We shall be creating a mautic site with FQDN as: https://mautic.networked.net
  • We shall be hosting the site on port number: 443
  • We shall be using a self signed SSL certificate
  • Host entry to ensure this website is reachable is done in the user PC, in absence of a DNS

Pre-requisites installation

  • Log into the webserver and run the below commands
ssh kedar@10.1.65.107
sudo apt install apache2 php7.2 php7.2-curl php7.2-gd php7.2-intl php7.2-json php7.2-mbstring php7.2-mysql php7.2-soap php7.2-xml php7.2-zip libapache2-mod-php7.2 
sudo apt install rsync nano openssl
sudo a2enmod ssl
sudo a2enmod rewrite
sudo systemctl restart apache2
sudo systemctl status apache2

Database Creation

  • Database will be created in a mariadb server which is installed into a container created on the host server (infrabase1). Latest mariadb server has been installed and run the below commands after an ssh into the mariadb server.
sudo mysql -u root -p
CREATE DATABASE mautic;
GRANT ALL PRIVILEGES ON mautic.* TO "mautic"@"%" IDENTIFIED BY "123456";
FLUSH PRIVILEGES;
quit;

Create self signed certificates

  • Log into the webserver and run the below commands
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/mautic.key -out /etc/ssl/certs/mautic.crt
  • You can use a commercial self signed certificate if you have one or can also use free Lets Encrypt certificate

Download Mautic

  • Download Mautix zip file from this url: https://www.mautic.org/download
  • Transfer this zip file using sftp or ftp or any other way to the webserver (10.1.65.107) in /home/kedar/ directory
  • Log into the webserver and run the below commands
cd /var/www/html
sudo mkdir mautic

Deploy Mautic

cd /home/kedar
unzip 2.16.2.zip
cd mautic
sudo rsync -avz . /var/www/html/mautic
  • Change the ownership of the mautic folder to apache user
cd /var/www/html
sudo chown -R www-data:www-data mautic/
sudo systemctl restart apache2
  • Create virtual host for the website
cd /etc/apache2/sites-available
sudo a2dissite 000-default.conf
sudo a2dissite default-ssl.conf
sudo nano mautic.conf
  • Add the below configuration in the mautic.conf file

<syntaxhighlight lang="apacheconf"> <IfModule mod_ssl.c>

       <VirtualHost _default_:443>
               ServerName      mautic.networked.net
               ServerAlias     mautic
               ServerAdmin     admin@networked.net
               DocumentRoot /var/www/html/mautic
               ErrorLog ${APACHE_LOG_DIR}/error.log
               CustomLog ${APACHE_LOG_DIR}/access.log combined
               SSLEngine on
               SSLCertificateFile      /etc/ssl/certs/mautic.crt
               SSLCertificateKeyFile /etc/ssl/private/mautic.key

<FilesMatch "\.(cgi|shtml|phtml|php)$">

                               SSLOptions +StdEnvVars
               </FilesMatch>
               <Directory /usr/lib/cgi-bin>
                               SSLOptions +StdEnvVars
               </Directory>

</VirtualHost> </IfModule>

  • Enable the site and Restart apache service
sudo a2ensite mautic.conf
sudo sysemctl restart apache2
  • Using a browser navigate to https://mautic.networked.com
    • Answer various questions based on some of the steps we have done above like db name, db user, db server etc.
    • Login to mautic using the admin credentials

Configure Cronjobs

  • Cronjobs are important to ensure mass updates can be queued up and run in batches. If in the the email settings, you have mentioned, queue emails instead of send immediately, email cron job will ensure that emails are sent and status is displayed in the dashboard.
  • It is always better to send emails in batch instead of sending immediately as it is more efficient way of sending emails.
  • Following cronjob should be configured.
    • ssh in to the webserver
crontab -e
  • Choose the choice by entering the number against the editor you want to use
  • At the end of the file add the below lines. These numbers have been picked up from the mautic documentation website
0,15,30,45 * * * * /usr/bin/php /var/www/html/mautic/app/console mautic:segments:update
5,20,35,50 * * * * /usr/bin/php /var/www/html/mautic/app/console mautic:campaigns:update
10,25,40,55 * * * * /usr/bin/php /var/www/html/mautic/app/console mautic:campaigns:trigger
0,15,30,45 * * * * /usr/bin/php /var/www/html/mautic/app/console mautic:emails:send
  • Save and exit
  • Check the status of the cron if it is running by executing the following command
sudo tail -f /var/log/syslog

Conclusion

  • We have a working mautic website hosted on an apache web server. Explore the corporate marketing automation tool