# Installation with NGINX

**URL:** <https://forum.mautic.org/t/installation-with-nginx/3401>\
**Category:** Product Support\
**Created:** [February 5, 2016, 9:57pm UTC](https://forum.mautic.org/t/installation-with-nginx/3401 "2016-02-05T21:57:52Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![gkrizek](https://avatars.discourse-cdn.com/v4/letter/g/9d8465/32.png) [@gkrizek](https://forum.mautic.org/u/gkrizek)\
**Post date:** [February 5, 2016, 9:57pm UTC](https://forum.mautic.org/t/installation-with-nginx/3401/1 "2016-02-05T21:57:52Z")

</div>

I’m trying to install Mautic on a server running NGINX 1.8. My first questions is, is version 1.8 supported? I see on their requirements it only says 1.1 with no ‘+’. That seems like a fairly old version of NGINX to be the only support version.  
  
  
  
I unziped the files into the /var/www/mautic/ directory and tried to access it in my browser but I get a 500 error every time. I can’t find anything in the error logs, so I’m not sure why it won’t load the files.  
  
  
  
Thanks

---

<div class="post-metadata">

**Author:** ![gkrizek](https://avatars.discourse-cdn.com/v4/letter/g/9d8465/32.png) [@gkrizek](https://forum.mautic.org/u/gkrizek)\
**Post date:** [February 5, 2016, 9:57pm UTC](https://forum.mautic.org/t/installation-with-nginx/3401/2 "2016-02-05T21:57:52Z")

</div>

I’m trying to install Mautic on a server running NGINX 1.8. My first questions is, is version 1.8 supported? I see on their requirements it only says 1.1 with no ‘+’. That seems like a fairly old version of NGINX to be the only support version.

I unziped the files into the /var/www/mautic/ directory and tried to access it in my browser but I get a 500 error every time. I can’t find anything in the error logs, so I’m not sure why it won’t load the files.

Thanks

---

<div class="post-metadata">

**Author:** ![zpetterd](https://avatars.discourse-cdn.com/v4/letter/z/f14d63/32.png) [@zpetterd](https://forum.mautic.org/u/zpetterd)\
**Post date:** [February 6, 2016, 7:28am UTC](https://forum.mautic.org/t/installation-with-nginx/3401/3 "2016-02-06T07:28:51Z")

</div>

Have a go with this config

```auto
server {
    listen 80;

    root /home/mautic/public_html;
    index index.html index.htm index.php;

    error_page 404 /index.php;
        error_page 405 = $uri;

    server_name mautic.example.com;

    access_log /var/log/access_log main;
    error_log /var/log/error_log;

    # redirect index.php to root
    rewrite ^/index.php/(.*) /$1 permanent;

    #######################################
    ## Start Mautic Specific config #####
    #######################################

    # redirect some entire folders
    rewrite ^/(vendor|translations|build)/.* /index.php break;

    location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to index.html
        # one option: try_files $uri $uri/ /index.php$is_args$args;
        try_files $uri /index.php$is_args$args;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }

    # Deny everything else in /app folder except Assets folder in bundles
    location ~ /app/bundles/.*/Assets/ {
        allow all;
    }
    location ~ /app/ { deny all; }

    # Deny everything else in /addons or /plugins folder except Assets folder in bundles
    location ~ /(addons|plugins)/.*/Assets/ {
        allow all;
    }
    #location ~ /(addons|plugins)/ { deny all; }

    # Deny all php files in themes folder
    location ~* ^/themes/(.*).php {
        deny all;
    }

    # Don't log favicon
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    # Don't log robots
    location = /robots.txt {
        access_log off;
        log_not_found off;
    }

    # Deny yml, twig, markdown, init file access
    location ~* /(.*).(?: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 ~ /. {
        deny all;
        access_log off;
        log_not_found off;
    }

    # Deny all grunt, composer files
    location ~* (Gruntfile|package|composer).(js|json)$ {
        deny all;
        access_log off;
        log_not_found off;
    }

    location ~ .php$ {
        fastcgi_split_path_info ^(.+.php)(/.+)$;

        fastcgi_keep_conn on;
        fastcgi_pass unix:/var/run/php-fpm/mautic.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
 add_header 'Access-Control-Allow-Origin' "*";

}

```

You will need to modify it to match your setup though (it actually came from a link on the Slack channel, not sure who it was)

---

<div class="post-metadata">

**Author:** ![gkrizek](https://avatars.discourse-cdn.com/v4/letter/g/9d8465/32.png) [@gkrizek](https://forum.mautic.org/u/gkrizek)\
**Post date:** [February 9, 2016, 8:00pm UTC](https://forum.mautic.org/t/installation-with-nginx/3401/4 "2016-02-09T20:00:00Z")

</div>

Thanks for the reply! I tried your config and replaced everything with my information as needed, but still getting a 500 error. This is really strange and not sure what’s causing it. I might go to the Slack channel and try my luck there as well.

---

<div class="post-metadata">

**Author:** ![manyk](https://avatars.discourse-cdn.com/v4/letter/m/0ea827/32.png) [@manyk](https://forum.mautic.org/u/manyk)\
**Post date:** [February 27, 2017, 12:07pm UTC](https://forum.mautic.org/t/installation-with-nginx/3401/5 "2017-02-27T12:07:01Z")

</div>

[quote=7945:@zpetterd]Have a go with this config

```auto
server {
    listen 80;

    root /home/mautic/public_html;
    index index.html index.htm index.php;

    error_page 404 /index.php;
        error_page 405 = $uri;

    server_name mautic.example.com;

    access_log /var/log/access_log main;
    error_log /var/log/error_log;

    # redirect index.php to root
    rewrite ^/index.php/(.*) /$1 permanent;

    #######################################
    ## Start Mautic Specific config #####
    #######################################

    # redirect some entire folders
    rewrite ^/(vendor|translations|build)/.* /index.php break;

    location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to index.html
        # one option: try_files $uri $uri/ /index.php$is_args$args;
        try_files $uri /index.php$is_args$args;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }

    # Deny everything else in /app folder except Assets folder in bundles
    location ~ /app/bundles/.*/Assets/ {
        allow all;
    }
    location ~ /app/ { deny all; }

    # Deny everything else in /addons or /plugins folder except Assets folder in bundles
    location ~ /(addons|plugins)/.*/Assets/ {
        allow all;
    }
    #location ~ /(addons|plugins)/ { deny all; }

    # Deny all php files in themes folder
    location ~* ^/themes/(.*).php {
        deny all;
    }

    # Don't log favicon
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    # Don't log robots
    location = /robots.txt {
        access_log off;
        log_not_found off;
    }

    # Deny yml, twig, markdown, init file access
    location ~* /(.*).(?: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 ~ /. {
        deny all;
        access_log off;
        log_not_found off;
    }

    # Deny all grunt, composer files
    location ~* (Gruntfile|package|composer).(js|json)$ {
        deny all;
        access_log off;
        log_not_found off;
    }

    location ~ .php$ {
        fastcgi_split_path_info ^(.+.php)(/.+)$;

        fastcgi_keep_conn on;
        fastcgi_pass unix:/var/run/php-fpm/mautic.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
 add_header 'Access-Control-Allow-Origin' "*";

}

```

You will need to modify it to match your setup though (it actually came from a link on the Slack channel, not sure who it was)[/quote]

Your config has a few issues.  
Check the comments from here [https://gist.github.com/that0n3guy/905c812c0f65e7ffb5ec](https://gist.github.com/that0n3guy/905c812c0f65e7ffb5ec) to learn more.

---

<div class="post-metadata">

**Author:** ![ricardomartins](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ricardomartins/32/198_2.png) [@ricardomartins](https://forum.mautic.org/u/ricardomartins)\
**Post date:** [June 16, 2017, 3:28am UTC](https://forum.mautic.org/t/installation-with-nginx/3401/6 "2017-06-16T03:28:23Z")

</div>

Be careful with last gist, because it exposes some php file like  
app/bundles/CoreBundle/Assets/js/libraries/ckeditor/filemanager/connectors/php/filemanager.php

---

<div class="post-metadata">

**Author:** ![Alcides](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@Alcides](https://forum.mautic.org/u/Alcides)\
**Post date:** [August 16, 2017, 1:04am UTC](https://forum.mautic.org/t/installation-with-nginx/3401/7 "2017-08-16T01:04:06Z")

</div>

Hello! @manyk@zpetterd and others.

Could you please post the virtualhost configuration lines that Works?

Thanks

---

<div class="post-metadata">

**Author:** ![theatereleven](https://avatars.discourse-cdn.com/v4/letter/t/85e7bf/32.png) [@theatereleven](https://forum.mautic.org/u/theatereleven)\
**Post date:** [August 16, 2017, 2:11am UTC](https://forum.mautic.org/t/installation-with-nginx/3401/8 "2017-08-16T02:11:31Z")

</div>

I’ve installed a few times with nginx at various versions. Documented the steps here:

[https://outergain.com/install-mautic-in-a-sub-folder-on-nginx/](https://outergain.com/install-mautic-in-a-sub-folder-on-nginx/)

---

<div class="post-metadata">

**Author:** ![Yosu\_Cadilla](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/yosu_cadilla/32/6206_2.png) [@Yosu\_Cadilla](https://forum.mautic.org/u/Yosu_Cadilla)\
**Post date:** [August 17, 2017, 8:16am UTC](https://forum.mautic.org/t/installation-with-nginx/3401/9 "2017-08-17T08:16:26Z")

</div>

Error 500 is usually related to HTTP server misconfiguration. An easy way to troubleshoot your HTTP server is to start with a very basic config file, then add parameters to it one by one.

---

<div class="post-metadata">

**Author:** ![Alcides](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@Alcides](https://forum.mautic.org/u/Alcides)\
**Post date:** [August 31, 2017, 1:50am UTC](https://forum.mautic.org/t/installation-with-nginx/3401/10 "2017-08-31T01:50:01Z")

</div>

Hello @theatereleven

Thanks for your help.

I looked at your POST and I have seein that you have added the following lines into your nginx virtual host setup file:

* * *

1. Edit your site’s server block.

The normal path is: /etc/nginx/sites-available/yoursite.com

## location /pages { try\_files $uri $uri/ /pages/?q=$uri&$args; }

## Did you only added this?

## location /pages { try\_files $uri $uri/ /pages/?q=$uri&$args; }

Is it enough to cover ALL Mautic needs to run on NGINX?  
Or have you added any other lines? If so, could you please share?

---

<div class="post-metadata">

**Author:** ![theatereleven](https://avatars.discourse-cdn.com/v4/letter/t/85e7bf/32.png) [@theatereleven](https://forum.mautic.org/u/theatereleven)\
**Post date:** [August 31, 2017, 1:53am UTC](https://forum.mautic.org/t/installation-with-nginx/3401/11 "2017-08-31T01:53:28Z")

</div>

Hey @Alcides,

Nginx doesn’t need any special configuring to run Mautic. There are certain PHP libraries needed, and the install will tell you if you don’t have them. The ONLY reason I had to edit my server block file is to tell nginx to allow a sub folder on my site to also host site executables. By default, your server block will tell nginx where your website files are (index.php, etc). So if you install mautic in a sub folder, nginx will not allow the index file in there to server anything up.

Hope I’m explaining that okay.

---

<div class="post-metadata">

**Author:** ![Alcides](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@Alcides](https://forum.mautic.org/u/Alcides)\
**Post date:** [August 31, 2017, 2:02am UTC](https://forum.mautic.org/t/installation-with-nginx/3401/12 "2017-08-31T02:02:12Z")

</div>

Hello @theatereleven  
Thanks for your attention and help.

I understood what you Said, but based on It why people add só many lines as following?

[quote=7945:@zpetterd]Have a go with this config

```auto
server {
    listen 80;

    root /home/mautic/public_html;
    index index.html index.htm index.php;

    error_page 404 /index.php;
        error_page 405 = $uri;

    server_name mautic.example.com;

    access_log /var/log/access_log main;
    error_log /var/log/error_log;

    # redirect index.php to root
    rewrite ^/index.php/(.*) /$1 permanent;

    #######################################
    ## Start Mautic Specific config #####
    #######################################

    # redirect some entire folders
    rewrite ^/(vendor|translations|build)/.* /index.php break;

    location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to index.html
        # one option: try_files $uri $uri/ /index.php$is_args$args;
        try_files $uri /index.php$is_args$args;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }

    # Deny everything else in /app folder except Assets folder in bundles
    location ~ /app/bundles/.*/Assets/ {
        allow all;
    }
    location ~ /app/ { deny all; }

    # Deny everything else in /addons or /plugins folder except Assets folder in bundles
    location ~ /(addons|plugins)/.*/Assets/ {
        allow all;
    }
    #location ~ /(addons|plugins)/ { deny all; }

    # Deny all php files in themes folder
    location ~* ^/themes/(.*).php {
        deny all;
    }

    # Don't log favicon
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    # Don't log robots
    location = /robots.txt {
        access_log off;
        log_not_found off;
    }

    # Deny yml, twig, markdown, init file access
    location ~* /(.*).(?: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 ~ /. {
        deny all;
        access_log off;
        log_not_found off;
    }

    # Deny all grunt, composer files
    location ~* (Gruntfile|package|composer).(js|json)$ {
        deny all;
        access_log off;
        log_not_found off;
    }

    location ~ .php$ {
        fastcgi_split_path_info ^(.+.php)(/.+)$;

        fastcgi_keep_conn on;
        fastcgi_pass unix:/var/run/php-fpm/mautic.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
 add_header 'Access-Control-Allow-Origin' "*";

}

```

You will need to modify it to match your setup though (it actually came from a link on the Slack channel, not sure who it was)[/quote]

---

<div class="post-metadata">

**Author:** ![theatereleven](https://avatars.discourse-cdn.com/v4/letter/t/85e7bf/32.png) [@theatereleven](https://forum.mautic.org/u/theatereleven)\
**Post date:** [August 31, 2017, 5:48am UTC](https://forum.mautic.org/t/installation-with-nginx/3401/13 "2017-08-31T05:48:47Z")

</div>

Hey @Alcides - Interesting. Looks like they’re trying to lock stuff down more? That doesn’t hurt! I’m going to try some of the above on one of my installs and see how it goes.

UPDATE: Finally added these to my config. Works! I’d recommend adding that stuff.

---

<div class="post-metadata">

**Author:** ![Alcides](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@Alcides](https://forum.mautic.org/u/Alcides)\
**Post date:** [September 26, 2017, 2:43pm UTC](https://forum.mautic.org/t/installation-with-nginx/3401/14 "2017-09-26T14:43:21Z")

</div>

@theatereleven

Could you please share what you have done?

I can not make mautic running well on NGINX.

My current issue is related with CSS and JS files.  
They are not beeing load.  
Do you have any ideia of what is this issue?

---

<div class="post-metadata">

**Author:** ![theatereleven](https://avatars.discourse-cdn.com/v4/letter/t/85e7bf/32.png) [@theatereleven](https://forum.mautic.org/u/theatereleven)\
**Post date:** [September 26, 2017, 8:01pm UTC](https://forum.mautic.org/t/installation-with-nginx/3401/15 "2017-09-26T20:01:42Z")

</div>

Hey @Alcides - not sure where you’re running into problems, but here’s a blog post I did on the steps that worked for me:

[https://outergain.com/install-mautic-in-a-sub-folder-on-nginx/](https://outergain.com/install-mautic-in-a-sub-folder-on-nginx/)

---

<div class="post-metadata">

**Author:** ![Alcides](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@Alcides](https://forum.mautic.org/u/Alcides)\
**Post date:** [September 27, 2017, 7:39pm UTC](https://forum.mautic.org/t/installation-with-nginx/3401/16 "2017-09-27T19:39:05Z")

</div>

Hi! @theatereleven  
I followed all you have done. But it is still not working.

My issue is the following error: “NetworkError: 404 Not Found - [https://m.MyDomain.com/mtc.js](https://m.MyDomain.com/mtc.js)”

How to reproduce:  
1 - Installed a fresh new mautic instance.  
2 - setup a simple Landing Page  
3 - Access the landing page.  
4 - the landing page appers well but I receive the message above.

Any idea?

---

<div class="post-metadata">

**Author:** ![theatereleven](https://avatars.discourse-cdn.com/v4/letter/t/85e7bf/32.png) [@theatereleven](https://forum.mautic.org/u/theatereleven)\
**Post date:** [September 27, 2017, 7:49pm UTC](https://forum.mautic.org/t/installation-with-nginx/3401/17 "2017-09-27T19:49:35Z")

</div>

Check this post: [https://www.mautic.org/community/index.php/4626-mtc-js-not-found/0](https://www.mautic.org/community/index.php/4626-mtc-js-not-found/0)

---

<div class="post-metadata">

**Author:** ![Alcides](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@Alcides](https://forum.mautic.org/u/Alcides)\
**Post date:** [September 27, 2017, 9:03pm UTC](https://forum.mautic.org/t/installation-with-nginx/3401/18 "2017-09-27T21:03:01Z")

</div>

Hi! @theatereleven

Thanks for your help.

Yes! I have done this.

I have added:  
location ~ mtc.js{  
try\_files $uri @phpstream;  
}

With this change, I have now “500 Internal Server Error” instead of 404.

So, I am in the same mood.

---

<div class="post-metadata">

**Author:** ![theatereleven](https://avatars.discourse-cdn.com/v4/letter/t/85e7bf/32.png) [@theatereleven](https://forum.mautic.org/u/theatereleven)\
**Post date:** [September 27, 2017, 9:09pm UTC](https://forum.mautic.org/t/installation-with-nginx/3401/19 "2017-09-27T21:09:39Z")

</div>

We probably need to see your nginx server block file at this point.

---

<div class="post-metadata">

**Author:** ![fususu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/fususu/32/215_2.png) [@fususu](https://forum.mautic.org/u/fususu)\
**Post date:** [September 28, 2017, 4:39am UTC](https://forum.mautic.org/t/installation-with-nginx/3401/20 "2017-09-28T04:39:08Z")

</div>

You should have this also on another block…

`location @phpstream {
    fastcgi_pass fastcgi_pass 127.0.0.1:9000;
	}`

or

`location @phpstream {
     fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; #or php5.0-sock... depends on your config
	}`

Just try and let me know if it works? I got this issue and not solve until now. See [https://www.mautic.org/community/index.php/8458-form-won-t-show-via-javascrip-404-not-found/0#p26198](https://www.mautic.org/community/index.php/8458-form-won-t-show-via-javascrip-404-not-found/0#p26198)

[Next page](https://forum.mautic.org/t/installation-with-nginx/3401.md?page=2)
