# Installing on NginX within a subfolder

**URL:** <https://forum.mautic.org/t/installing-on-nginx-within-a-subfolder/3053>\
**Category:** Product Support\
**Created:** [December 23, 2015, 2:13pm UTC](https://forum.mautic.org/t/installing-on-nginx-within-a-subfolder/3053 "2015-12-23T14:13:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris76](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/chris76/32/522_2.png) [@Chris76](https://forum.mautic.org/u/Chris76)\
**Post date:** [December 23, 2015, 2:13pm UTC](https://forum.mautic.org/t/installing-on-nginx-within-a-subfolder/3053/1 "2015-12-23T14:13:49Z")

</div>

Hello,  
  
  
  
I’m trying to install Mautic on a webserver with Nginx BUT within a subfolder like: [www.domain.com/mautic](http://www.domain.com/mautic)  
  
  
  
Now I was trying to use the example from github [https://gist.github.com/joglomedia/487c7c6a78892d2f1fd7](https://gist.github.com/joglomedia/487c7c6a78892d2f1fd7) and came up with:

Code:

location ^~ /mautic { alias /var/www/domain.com/mautic; index index.php;

```
charset utf-8;

rewrite ^/index.php/(.*) /$1 permanent;

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

# 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; }

# 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 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;
}

#######################################
## End Mautic Specific config #####
#######################################

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

    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;

    fastcgi_buffer_size 128k;
    fastcgi_buffers 256 16k;
    fastcgi_busy_buffers_size 256k;
    fastcgi_temp_file_write_size 256k;
}

```

}

  
But on www.domain.com/mautic I receive a file called Download.  
www.domain.com/mautic/index.php redirects to www.domain.com/mautic/index.php/index.php/installer  
and the error log says: open() "/var/www/domain.com/mautic/index.php/index.php/installer" failed (20: Not a directory)  
www.domain.com/mautic/index.php/installer just yields the error log entry: open() "/var/www/domain.com/mautic/index.php/installer" failed (20: Not a directory)  
  
I assume there is some logic with the nested location for NginX wrong - but what can it be?

---

<div class="post-metadata">

**Author:** ![Chris76](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/chris76/32/522_2.png) [@Chris76](https://forum.mautic.org/u/Chris76)\
**Post date:** [December 23, 2015, 2:13pm UTC](https://forum.mautic.org/t/installing-on-nginx-within-a-subfolder/3053/2 "2015-12-23T14:13:49Z")

</div>

Hello,

I’m trying to install Mautic on a webserver with Nginx BUT within a subfolder like: [www.domain.com/mautic](http://www.domain.com/mautic)

Now I was trying to use the example from github [https://gist.github.com/joglomedia/487c7c6a78892d2f1fd7](https://gist.github.com/joglomedia/487c7c6a78892d2f1fd7) and came up with:

[code]location ^~ /mautic {  
alias /var/www/domain.com/mautic;  
index index.php;

```
charset utf-8;

rewrite ^/index.php/(.*) /$1 permanent;

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

# 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; }

# 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 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;
}

#######################################
## End Mautic Specific config #####
#######################################

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

    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;

    fastcgi_buffer_size 128k;
    fastcgi_buffers 256 16k;
    fastcgi_busy_buffers_size 256k;
    fastcgi_temp_file_write_size 256k;
}

```

}  
[/code]

But on [www.domain.com/mautic](http://www.domain.com/mautic) I receive a file called Download.  
[www.domain.com/mautic/index.php](http://www.domain.com/mautic/index.php) redirects to [www.domain.com/mautic/index.php/index.php/installer](http://www.domain.com/mautic/index.php/index.php/installer)  
and the error log says: open() “/var/www/domain.com/mautic/index.php/index.php/installer” failed (20: Not a directory)  
[www.domain.com/mautic/index.php/installer](http://www.domain.com/mautic/index.php/installer) just yields the error log entry: open() “/var/www/domain.com/mautic/index.php/installer” failed (20: Not a directory)

I assume there is some logic with the nested location for NginX wrong - but what can it be?

---

<div class="post-metadata">

**Author:** ![dbhurley](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/dbhurley/32/2_2.png) [@dbhurley](https://forum.mautic.org/u/dbhurley)\
**Post date:** [December 23, 2015, 2:29pm UTC](https://forum.mautic.org/t/installing-on-nginx-within-a-subfolder/3053/3 "2015-12-23T14:29:38Z")

</div>

Here is a second alternative config for NGINX: [https://gist.github.com/that0n3guy/905c812c0f65e7ffb5ec](https://gist.github.com/that0n3guy/905c812c0f65e7ffb5ec)

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [February 2, 2020, 10:56pm UTC](https://forum.mautic.org/t/installing-on-nginx-within-a-subfolder/3053/4 "2020-02-02T22:56:22Z")

</div>


