Mautic Community Forums

Mautic not in root dir?

Hi There,



Super new to Mautic Self Hosted, but having been priced out of HubSpot + Marketo, I was more than pleasantly surprised to find Mautic… in fact, it’s pretty amazing!



I have 2 questions which I’d be super grateful for insight on


  1. Can I install Mautic in an entirely different DIR to my WordPress install?

    E.g.

    root/wordpress/*wordpress install

    root/mautic/*mautic install



    or do I need to do:

    root/wordpress/*wordpress install

    root/wordpress/mautic/*mautic install


  2. Can I point to the Mautic DIR using a subdomain?

    I’m trying to use marketing.example.com.



    This would mean all my landing pages are published at:

    published at marketing.example.com/[landingpage]



    Will this work, or would there be consequences e.g mess up the tracking pixel?

    (I currently can’t get this to work, but that’s another story).



    p.s. are there any “getting started” docs, I can see?

Hi There,

Super new to Mautic Self Hosted, but having been priced out of HubSpot + Marketo, I was more than pleasantly surprised to find Mautic… in fact, it’s pretty amazing!

I have 2 questions which I’d be super grateful for insight on

  1. Can I install Mautic in an entirely different DIR to my WordPress install?
    E.g.
    root/wordpress/*wordpress install
    root/mautic/*mautic install

or do I need to do:
root/wordpress/*wordpress install
root/wordpress/mautic/*mautic install

  1. Can I point to the Mautic DIR using a subdomain?
    I’m trying to use marketing.example.com.

This would mean all my landing pages are published at:
published at marketing.example.com/[landingpage]

Will this work, or would there be consequences e.g mess up the tracking pixel?
(I currently can’t get this to work, but that’s another story).

p.s. are there any “getting started” docs, I can see?

Hi!

  1. You can install Mautic to whatever dir you want. I wouldn’t install it into the WP root dir directly because that would cause Mautic rewriting some files (index.php, .htaccess) of WP or the other way around. I think that wasn’t your question, but I mention it just to be sure.

All this is fine:
root/wordpress/*wordpress install
root/mautic/*mautic install
root/wordpress/*wordpress install
root/wordpress/mautic/*mautic install

  1. Yes, Mautic can be in a subdomain. Tracking pixel then has to have the subdomain in its URL as well.

Here is the Getting Started guide: https://www.mautic.org/getting-started/

@Sellout (or anyone else who can use it):

Here is a working config for Wordpress & Mautic on Nginx / CentOS 7

Not sure if this the correct place to share this, but it may be useful to someone who runs across this post.

## Where nginx is the user and web is the group.
user nginx web;  
 ## have nginx manage the worker pool automagically
worker_processes auto; 

## default error log location.
error_log /var/log/nginx/error.log;   
## default process id location.
pid /run/nginx.pid;  

## Connection process handling methods.
events {
    use epoll;
    worker_connections 1024;
    multi_accept on;
}

http {
    ## Handle all the different types of files. Like RSS, CSS, GIF, etc...
    include             /etc/nginx/mime.types; 
    default_type        application/octet-stream;

    ## Format used for the text in the logs
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';   

    ## Default access log locaion.
    access_log  /var/log/nginx/access.log  main;     
    
    ## These three items are for file handling performance on linux kernels newer than 2.2
    sendfile          on;      # Handles how the kernel manages files and headers related to them. 
    tcp_nopush          on;      # Tells nginx how to use/handle network level buffers.
    tcp_nodelay         on;      # Same thing here - these two work together.

    # Tells nginx how long to keep a socket connection open if nothing is happening over it.
    keepalive_timeout   65;              
    types_hash_max_size 2048;   
    # This is a performance tweak that tells nginx how large its hash table settings should be.
    # (On startup nginx pulls informaiton out of your config and stores things like the server 
    # name, what mime types are supported and other goodies. If your processor has a 64 
    # bit cache line size - most do these days - then your has_max_size should be evenly
    # divisible by it. )

    # Turn on compression (to use less bandwidth) and setup some types that will be compressed.
    gzip on;     
    gzip_min_length 1000;  
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    include /etc/nginx/conf.d/*.conf;

    open_file_cache max=1000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 5;
    open_file_cache_errors off;
    
    # Tell nginx how big a file can be that is uploaded. (This needs to match your PHP and PHP-FPM configuration.)
    client_max_body_size 100m;
    # Tell nginx what kind of index you're using.
    index index.php;

    server {
        # Listen on 80 but redirect to 443
        listen 80;
        server_name host.domain.tld;
        server_tokens off;
        return 301 https://$host$request_uri;
    }

    ## The secure nginx server instance
    server {
        listen                    443 ssl;
        server_name               subdomain.domain.tld;
        ssl                     on;  
        ssl_certificate           /etc/pki/tls/certs/your-cert-public-key-bundle.crt;
        ssl_certificate_key       /etc/pki/tls/certs/your-private.key;
        ssl_protocols             SSLv3 TLSv1; 
        ssl_ciphers               ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP; 
        ssl_prefer_server_ciphers on;

       # If you want to see the logs specific to the domain you're working with do this.
        access_log /var/log/nginx/your-domain/access.log;
        error_log /var/log/nginx/your-domain/error.log;
        
        # Setup wordpress installation as the root (drop your mautic install into /var/www/your-domain/wordpress/mautic)
        root /var/www/your-domain/wordpress;

        location / {
            try_files $uri $uri/ /index.php?$args;
        }

        ##### Mautic Specific ######
        # For any inbound request to the mautic directory try using mautic index.php to handle the requests before you give up.
        location /mautic/ {
            try_files $uri $uri/ /mautic/index.php?$args;
        }

        # For any inbound requests that have non-exisiting files with these extentions:
        # Try passing the request to mautic before you give up and throw a 404.
        # This is particularly important in order to get paths like this to work correctly:
        # https://host.domain.tld/mautic/form/generate.js?id=1 (If you look at the Mautic code there is a public route 
        # - mautic_form_generateform -  that handles the creation of this "file".)
        #  Normally files like this would be handled by nginx as "physical files", but in this case we want nginx to 
        # check with mautic to see if it has what the request is looking for.) 
        location ~ /mautic/(.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)){
            # .gif and .js files here are not showing up.
            try_files $uri $uri/ /mautic/index.php?$args;
        }
        ##### End Mautic ###########

        location = /favicon.ico {
            log_not_found off;
            access_log off;
        }

        location = /robots.txt {
            allow all;
            log_not_found off;
            access_log off;
        }

        location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
            expires max;
            log_not_found off;
        }

        location ~ /.ht {
            deny all;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }

        location ~ [^/].php(/|$) {
            if (!-f $document_root$fastcgi_script_name) {
                return 404;
            }
            fastcgi_index            index.php;
            fastcgi_param            PATH_INFO        $fastcgi_script_name;
            fastcgi_param            SCRIPT_FILENAME  $document_root$fastcgi_script_name;  # same path as above
            fastcgi_pass             unix:/var/run/php5-fpm.sock;
            fastcgi_split_path_info  ^(.+?.php)(/.*)$;
            include                  /etc/nginx/fastcgi_params;
        }
    }
}