# how to install mautic on nginx subfolder

**URL:** <https://forum.mautic.org/t/how-to-install-mautic-on-nginx-subfolder/4086>\
**Category:** Product Support\
**Created:** [June 4, 2016, 12:25pm UTC](https://forum.mautic.org/t/how-to-install-mautic-on-nginx-subfolder/4086 "2016-06-04T12:25:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rufh\_s](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@rufh\_s](https://forum.mautic.org/u/rufh_s)\
**Post date:** [June 4, 2016, 12:25pm UTC](https://forum.mautic.org/t/how-to-install-mautic-on-nginx-subfolder/4086/1 "2016-06-04T12:25:14Z")

</div>

Hello,  
  
  
  
my other domain is running mautic without any issues , but I need to setup another domain recently moved to Nginx ( Amazon ec2)  
  
  
  
I prefer to install on subfolder [domain.com/em](http://domain.com/em) , I have following setup sites-available/default.conf

Code:

server { listen 80; server\_name domain.com;

access\_log /var/log/nginx/domain.com.access\_log;  
error\_log /var/log/nginx/domain.com.error\_log;

root /var/www/html;  
index index.php index.htm index.html;

include /etc/nginx/global/wordpress.conf;  
include /etc/nginx/global/restrictions.conf;  
include /etc/nginx/global/mautic.conf;  
}

  
& mautic.conf

Code:

location /em/ { # 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; root /var/www/html/em; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } 
## Default vhost directives configuration, use only one config.

```
#include /etc/nginx/conf.vhost/site_default.conf;

## MAUTIC CUSTOM DIRECTIVE SETTINGS ##

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

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

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

## Need modification, causing error 404
# Deny everything else in /addons or /plugins folder except Assets folder in bundles
#location ~ /(addons|plugins)/.*/Assets/ {
# allow all;
# access_log off;
#}
#location ~ /(addons|plugins)/ { deny all; }

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

# 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 grunt, composer files
location ~* (Gruntfile|package|composer).(js|json)$ {
    deny all;
    access_log off;
    log_not_found off;
}

## END OF MAUTIC SETTINGS ##

# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ /em/.+.php$ {
        # Zero-day exploit defense.
        # http://forum.nginx.org/read.php?2,88845,page=3
        # Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
        # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine. And then cross your fingers that you won't get hacked.
        try_files $uri =404;

        fastcgi_split_path_info ^(.+.php)(/.+)$;
        #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

        include fastcgi_params;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #fastcgi_intercept_errors on;
        fastcgi_pass 127.0.0.1:9000;
}

## Uncomment to enable error page directives configuration.
#include /etc/nginx/conf.vhost/errorpage.conf;

```

  
my wordpress site works perfectly with fastcgi\_pass 127.0.0.1:9000; on mautic it says "The site is currently offline due to encountering an error”  
  
I have not crossed installation process but I can use aws rds as database right?  
  
any help would be greatly appreciated

---

<div class="post-metadata">

**Author:** ![rufh\_s](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@rufh\_s](https://forum.mautic.org/u/rufh_s)\
**Post date:** [June 4, 2016, 12:25pm UTC](https://forum.mautic.org/t/how-to-install-mautic-on-nginx-subfolder/4086/2 "2016-06-04T12:25:14Z")

</div>

Hello,

my other domain is running mautic without any issues , but I need to setup another domain recently moved to Nginx ( Amazon ec2)

I prefer to install on subfolder [domain.com/em](http://domain.com/em) , I have following setup sites-available/default.conf

[code] server {  
listen 80;  
server\_name [domain.com](http://domain.com);

access\_log /var/log/nginx/domain.com.access\_log;  
error\_log /var/log/nginx/domain.com.error\_log;

root /var/www/html;  
index index.php index.htm index.html;

include /etc/nginx/global/wordpress.conf;  
include /etc/nginx/global/restrictions.conf;  
include /etc/nginx/global/mautic.conf;  
}[/code]

& mautic.conf [code]  
location /em/ {  
# 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;  
root /var/www/html/em;  
# Uncomment to enable naxsi on this location  
# include /etc/nginx/naxsi.rules  
}

## Default vhost directives configuration, use only one config.

```
#include /etc/nginx/conf.vhost/site_default.conf;

## MAUTIC CUSTOM DIRECTIVE SETTINGS ##

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

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

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

## Need modification, causing error 404
# Deny everything else in /addons or /plugins folder except Assets folder in bundles
#location ~ /(addons|plugins)/.*/Assets/ {
# allow all;
# access_log off;
#}
#location ~ /(addons|plugins)/ { deny all; }

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

# 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 grunt, composer files
location ~* (Gruntfile|package|composer).(js|json)$ {
    deny all;
    access_log off;
    log_not_found off;
}

## END OF MAUTIC SETTINGS ##

# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ /em/.+.php$ {
        # Zero-day exploit defense.
        # http://forum.nginx.org/read.php?2,88845,page=3
        # Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
        # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine. And then cross your fingers that you won't get hacked.
        try_files $uri =404;

        fastcgi_split_path_info ^(.+.php)(/.+)$;
        #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

        include fastcgi_params;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #fastcgi_intercept_errors on;
        fastcgi_pass 127.0.0.1:9000;
}

## Uncomment to enable error page directives configuration.
#include /etc/nginx/conf.vhost/errorpage.conf;

```

[/code]

my wordpress site works perfectly with fastcgi\_pass 127.0.0.1:9000; on mautic it says "The site is currently offline due to encountering an error”

I have not crossed installation process but I can use aws rds as database right?

any help would be greatly appreciated

---

<div class="post-metadata">

**Author:** ![rufh\_s](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@rufh\_s](https://forum.mautic.org/u/rufh_s)\
**Post date:** [June 5, 2016, 9:22am UTC](https://forum.mautic.org/t/how-to-install-mautic-on-nginx-subfolder/4086/3 "2016-06-05T09:22:35Z")

</div>

bump! I can pay if need be , please reach me out , thanks

---

<div class="post-metadata">

**Author:** ![rufh\_s](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@rufh\_s](https://forum.mautic.org/u/rufh_s)\
**Post date:** [June 8, 2016, 5:54am UTC](https://forum.mautic.org/t/how-to-install-mautic-on-nginx-subfolder/4086/4 "2016-06-08T05:54:30Z")

</div>

please close this , I am trying [mautic.com](http://mautic.com) and if need be would be switching to pro , have an issue there too guess its better to start new topic?
