Magento 2 in a subfolder of Nginx

Using Nginx 1.4.6 on Ubuntu, I am trying to configure Magento 2 to run in a subfolder.

I already have some other projects in /var/wwwthat set up like this:

server {
    server_name website.com;

    root /var/www/;

    location /p1/ {
        # config
    }

    location /p2/ {
        # config
    }
}

But now my Magento installation is in /mnt/storage/demo/demo-magento2, and I cannot find a way to include it in this server block.

I tried using my configuration for Nginx ( https://github.com/magento/magento2/wiki/Nginx-Configuration-Settings-and-Environment-Variables ). So, I added this location block to the server block configuration:

location /demos/demo-magento2/ {
  set $MAGE_ROOT /mnt/storage/demo-magento2/;
  set $MAGE_MODE developers;
  include /mnt/storage/demo-magento2/nginx.conf.sample;
}

And Nginx keeps returning this error to me:

2015/10/19 18:15:04 [emerg] 6250#0: location "/setup" is outside location "/demos/demo-magento2/" in /mnt/storage/demo-magento2/nginx.conf.sample:27

I am completely new to Nginx, so can someone explain to me how to understand this?

+4
2

@Memes, :

location /demos/demo-magento2/ {
  set $MAGE_ROOT /mnt/storage/demo-magento2/;
  set $MAGE_MODE developers;
  include /mnt/storage/demo-magento2/nginx.conf.sample;
}

:

location /demos/demo-magento2/ {
  set $MAGE_ROOT /mnt/storage/demo/demo-magento2/;
  set $MAGE_MODE developers;
  include /mnt/storage/demo/demo-magento2/nginx.conf.sample;
}

, demo/subpath. nginx !

+1

Nginx , ; Magento nginx.conf.sample "location", "" . ; , .

root, :

upstream fastcgi_backend {
        server unix:/var/run/php5-fpm.sock;
}

server {
    listen 80;
    server_name server.dev;
    set $MAGE_ROOT /path/to/magento2;
    set $MAGE_MODE developer;
    include /path/to/magento2/nginx.conf.sample;
 }

Ubuntu-nginx, /etc/nginx/sites -available, .

+1

Source: https://habr.com/ru/post/1612298/


All Articles