Install Mautic in a Sub Folder on NGINX

Written by
on August 11, 2017

For those of you who don’t know what Mautic is, it’s a powerhouse of an application for list building, marketing automation, sales funnels… and MORE!

And the incredible part? It’s FREE to use on your own server and site — you just need to know enough about Linux administration to set it up.

You can setup Mautic at a sub domain, but I wanted to install it within a sub folder. This would mean any landing pages created were at vs¬†However, installing in a sub folder on nginx wasn’t something many people were talking about when I first began with Mautic. So after trial and error, throwing computers out the window and destroying my office with a light saber, it began to work.

Here are the installation steps:

Opening Information:

  1. These steps assume ‘’ equals your actual website.
  2. ‘Data’ is the sub folder you’re installing Mautic into — The name is completely up to you.
  3. Your nginx sites are located in /var/www/
  4. Your PHP version is 7

Also note: We use Ubuntu and/or Debian. If you’re on a different distro, you may have to adjust a few commands.

1) Create the subfolder you want to run mautic out of.

Example: http://yoursitecom/pages/

2) Get the latest Mautic files.

From a command line, navigate to your folder. Example: cd /var/www/ and get the latest files:

wget –level=0

If you need an older version, type similar to:

wget –level=0

4) Unzip the installation files.

Simply type:

unzip latest

5) Remove the zipped file.

rm latest

(add the .zip extension for a version, example: rm

6) Change ownership on the installation folder(s):

chown -R www-data:www-data /var/www/

create a folder called ‘logs’ in pages/app (if it doesn’t exist). Then…

chown -R www-data:www-data /var/www/

Next: Server Config (based on Debian LEMP):

1) Edit php.ini file.

Add this line to the bottom of your your php.ini file:

always_populate_raw_post_data = -1

2) Install PHP packages

You may already have these items installed.

apt-get install php7-imap
apt-get install php7-intl
apt-get install php7-mcrypt

3) Enable mcrypt:

ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/mcrypt.ini
php5enmod mcrypt

4) Edit your site’s server block.

The normal path is: /etc/nginx/sites-available/

location /pages {
try_files $uri $uri/ /pages/?q=$uri&$args;

5) Restart nginx and php7-fpm

service nginx restart
service php7-fpm restart

6) Create mysql database for Mautic

create database yourmauticdb;
grant all on yourmauticdb.* to ‘yourmauticdbuser’ identified by ‘thepasswordyouwant’;
flush privileges;

Finally, the installation!

7) Go to

At this step, the installer will let you know if anything on your server isn’t ready for Mautic. This includes missing packages, outdated packages, etc. You’ll need to fix each item until you get the green Ready to Install as shown below.

8) Database information.

Next you’ll need to enter in your database information from step 6. You’re installing into a clean database, so no need to save existing tables. As long as the database info checks out, the installer will continue.

9) General Settings

The next step will prompt for general admin info such as email, name and password.

10) Email Configuration

Next up is your mail server configuration. We recommend SendGrid or SparkPost. The information below shows setting up as an SMTP server. But you can also setup with an API, which is recommended.

*You can skip this and setup the mail under the “Configuration Settings” once the installation completes.


11) Setup Cron

You’ll need to schedule cron jobs to keep things updated on the mautic instance.

a) from a command line type:

crontab -e

b) paste in the following lines:

*/5 * * * * php /var/www/ mautic:broadcasts:send
*/5 * * * * php /var/www/ mautic:segments:update
*/5 * * * * php /var/www/ mautic:campaigns:rebuild
*/5 * * * * php /var/www/ mautic:campaigns:trigger
*/5 * * * * php /var/www/ mautic:emails:send
*/5 * * * * php /var/www/ mautic:iplookup:download
*/5 * * * * php /var/www/ mautic:social:monitoring

*Note: the above tells each job to run every 5 minutes. For some jobs, this is complete overkill, so schedule according to your needs. Also, you may not need all of these jobs. For example, if you haven’t setup mautic to queue mail, then you don’t need it to have email send as a cron job.

The cron layout is:

minute hour day-of-month month day-of-week command

c) Save the file and then type:

run-parts /etc/cron.daily

To check the status of your cron jobs, type this in a terminal window:

/etc/init.d/cron status


Nicely done! Now the fun begins…

Would you like to learn more?

Get free marketing tips from Outer Gain! We help people sell beyond their reach!

Leave a Reply

Your email address will not be published. Required fields are marked *