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.0-imap
apt-get install php7.0-intl
apt-get install php7.0-mcrypt

3) Edit your site’s server block file.

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

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

Also, adding these restrictions will help nginx work for you and secure your installation:

# Deny everything else in /app folder except Assets folder in bundles
location ~ /content/app/bundles/.*/Assets/ {
allow all;
location ~ /content/app/ { deny all; }# Deny everything else in /addons or /plugins folder except Assets folder in bundles
location ~ /content/(addons|plugins)/.*/Assets/ {
allow all;
#location ~ /content/(addons|plugins)/ { deny all; }# Deny all php files in themes folder
location ~* /content/themes/(.*)\.php {
deny all;
}# Deny yml, twig, markdown, init file access
location ~* /content/(.*)\.(?:markdown|md|twig|yaml|yml|ht|htaccess|ini)$ {
deny all;
access_log off;
log_not_found off;
}# Deny all attempts to access hidden files/folders such as .htaccess, .htpasswd, .DS_Store (Mac), etc…
location ~ /content/\. {
deny all;
access_log off;
log_not_found off;
}# Deny all grunt, composer files
location ~* /content(Gruntfile|package|composer)\.(js|json)$ {
deny all;
access_log off;
log_not_found off;
Here’s a sample config for reference. In this sample, the Mautic installation is in the ‘content’ folder:
server {
listen 80;
listen [::]:80;root /var/www/;
access_log /var/www/;
error_log /var/www/;
index index.php index.html;


location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?q=$uri&$args;
#try_files $uri $uri/ =404;

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

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;


4) Restart nginx and php7-fpm

service nginx restart
service php7-fpm restart

5) Create mysql database for Mautic

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

Finally, the installation!

6) 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.

*Note: if your installation doesn’t start, check your site log file. You might need the PHP XML extension: apt-get install php-xml

7) 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.

8) General Settings

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

9) 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.


10) 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!

2 thoughts on “Install Mautic in a Sub Folder on NGINX

  1. Hi , thank you for your guide but this is doesn’t work :(.
    setup nginx + php7-fpm
    Config (i just have for test):

    server {

    listen 80;

    location / {
    try_files $uri $uri/ /$uri&$args;


    2017/09/10 09:37:59 [error] 19418#19418: *1 openat() “/var/www/kedaranatha/data/www/” failed (20: Not a directory), client:, server:, request: “GET /index.php/installer HTTP/1.1”, host: “”

    browser error:
    404 Not Found


Leave a Reply

Your email address will not be published.

UkuuPeople vs Follow Hook;
September 9, 2020
SEO Tips;
November 5, 2019
The Best iPhone Rig;
August 27, 2019
The Right Domain Name;
June 18, 2019
Outer Gain