Knowledge Base

Safest way to upgrade Mautic (AMS)

How many times have you gone to do an upgrade of Mautic and it failed only to leave you hanging without a system and running around looking for a solution.

At Surge we believe in fail safe methodologies to ensure 100% uptime for our customers.

With the release of Mautic 4.x we have noticed many upgrade issues both with current instances and monitoring the forum, as such we have put together a small tutorial on how to best upgrade your instance with ability to test and confirm in a temp staging environment before going to live.

This tutorial will assume the following:
1. You have ssh access to your instance server
2. The web server you are running is nginx
3. You have basic knowledge of working inside terminal.

With that lets jump in:

Start off by accessing your server via ssh.

Here are the steps to take and commands that go with it.

1. Make a backup of the ams base files. For this you need to know where you version of mautic (AMS) is installed.
cd /var/www/ams/
tar -czvf ams-files-5feb22.tar.gz *. (This will create a tar file of your entire directory)
mv ams-files-5feb22.tar.gz /root/. (if you are on AWS mv /home/ubuntu/)

2. Make a backup for the active database
mysqldump -u root ams > ams-db-5feb22.sql (where we have ams you can replace with the name of your Mautic database – over here we are not going to zip the sql as we will be using it in the next few steps)

3. Go ahead and create a staging directory
mkdir /var/www/stage

4. Copy the tar file we created to the stage directory and extract it
cd /var/www/stage
cp /root/ams-files-5feb22.tar.gz .
tar -xzvf ams-files-5feb22.tar.gz

5. Lets give this directory the correct permissions and ownership
chown -R www-data:www-data /var/www/stage

6. Now we can go and create a staging DB inside mysql
mysql -u root
This will take you into the mysql command line, here we will create the staging database.
CREATE DATABASE staging DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
GRANT ALL ON staging.* TO ‘dbuser’@’localhost’ IDENTIFIED BY ‘password’;
FLUSH PRIVILEGES;
quit

7. Now lets import the original database into the new one we created:
cd /root
mysql -u root staging < ams-db-5feb22.sql.

8. Now we need to update our configuration files cd /var/www/mautic/app/config (All the configurations are held in the local.php file) There are a number of parameters to look out for an change here.
Find these lines and change the values according to your changes in the steps above: vim local.php

‘db_name’ => ‘mautic’, —->. here you would change mautic to staging (the name of the database we created in step 6.
‘cache_path’ => ‘/var/www/mautic/app/../var/cache’, —> change name of directory to stage
‘log_path’ => ‘/var/www/mautic/app/../var/logs’, —> change name of directory to stage
‘tmp_path’ => ‘/var/www/mautic/app/../var/tmp’, —> change name of directory to stage
‘upload_dir’ => ‘/var/www/mautic/app/../media/files’, —> change name of directory to stage
‘form_upload_dir’ => ‘/var/www/mautic/app/../media/files/form’, —> change name of directory to stage
‘report_temp_dir’ => ‘/var/www/mautic/app/../media/files/temp’, —> change name of directory to stage

Save and exit the file.

9. Next lets go delete the old cache:
rm -rf /var/ww/stage/var/cache/*

At this stage we are ready to go ahead and upgrade. If you want, you can first change the web server configuration to test that everything is working on the staging environment.
Remember we are working on nginx server, but the same would apply for apache2

10. Change the directory the webserver is looking for as the root directory.
vim /etc/nginx/conf.d/mautic.conf
Change your root directory to point to your stage directory /var/www/stage

Test your changes
nginx -t
Then go ahead and restart your nginx server
systemctl restart nginx

Now if you go to your AMS instance via a webbrowser everything should seem exactly the same.

Lets go ahead and update to the latest version of Mautic
cd /var/www/stage/bin
php console mautic:update:apply
php console mautic:update:apply –finish

Hopefully everything should go fine and if not all you need to do is change your server config file to point back to your original directory.

If you do run into any troubles, feel free to contact us for some quick answers and professional support

Protected: Installing Metabase BI & Building Customized BI For the AMS

Password Protected

To view this protected post, enter the password below:

Installing the Firebase Plugin for Mobile App Push Notification

How incredible would it be if the AMS could send Push Notifications to your app?  Well yes you can do this with OneSignal, however not everyone is using OneSignal and we have found that many of our customers are using Firebase. So there is a company that has released...

I sent an email and made a sale!

This is a sentence I am always surprised to hear from our clients.  So many people are under the impression that e-mails don't work anymore.  People are focused on social platforms, text messages and whatsapp. We meet so many clients that have legacy data that they...

Using Campaigns to Manage Sales Follow Up Cycle

In continuation from our previous post on "Using Campaigns to Improve Sales Cycle" we now move into using Mautic campaigns to help the sales team follow up with leads that come in. Firstly we consulted with our clients on their needs, and in a very general case what...

Using Campaigns to Improve Sales Cycle

The AMS has many hidden features that can be used in conjunction to improve your overall sales cycle. At Surge we have used advanced campaigns and logic to help increase a business overall sales cycle and to boost conversion rates. How did we do this ? We started off...

E-Mail Frequency – Is Too Little Too Much or Vice-a-Versa

What a question to ask ? Probably the most debated question among marketeers throughout time (or at least since email was around). Everyone has their own opinion, and each opinion is valid and correct. There is no real right or wrong answer over here. At Surge we...

Unique Discount Code Distribution System

Challenge There is an inherent challenge when working with mautic and setting up unique discount codes. There are many instances where you might want to distribute a unique one time discount code. We have found this necessary in a few instances for example: Signup to...

Trigger Email on New WooCommerce Order

With the AMS you have the ability to move away from the standard emails being sent out from WooCommerce.  This presents a great way to have nicer order notifications and better tracking using the AMS. Today we will focus on how this can work using MakeWebBetter Mautic...

Updating Mautic WhiteLabeler to correct version

Often when there is a new release of Mautic, those of us using Mautic Whitelabeller have the frustration that it is not compatible with the current version. Here are the steps to correct this: Unzip the file, then go and edit the file compare.php

SSL Issues with www and non-www records

I have used certbot LetsEncrypt for hundreds of sites and usually I go ahead and set up the certifications without a problem and everything works well. Well this was the case until we came to a launch of a pretty big client, it was late at night and I set up the...