2

I want to configure a multistore shop like this:

domain1

domain2

The store code approach is not possible because we need to have the same store code multiple times.

What would be the best way to achieve this with nginx?

My configuration: Ubuntu 16.04LTS, PHP7.1(FPM), nginx/1.10.3, Magento 2.2.2 CE

  • So you want to setup these things on your localhost right ? – zed Blackbeard Feb 28 '18 at 7:28
  • store/website code is exactly what you need, this is the most safest and easiest solution. – MagenX Feb 28 '18 at 8:22
4

I've done a setup with Magento 2.2 and nginx before, but with subdomains instead of folders.

So the setup was:

  • nl.domain1.com, en.domain1.com,...
  • nl.domain2.com, en.domain2.com,...

etc.

This is a modified version of the setup, maybe it helps you getting started. Another/additional idea: Create 2 nginx config files (one for each domain) and use alias for the subfolders?

#default mapping
map $http_host $magesite {
        127.0.0.1 "website1_storeview1";
}

map $http_host $MAGE_SUBLOCATION {
    www.domain1.com /nl;
    www.domain1.com /en;
    www.domain1.com /de;
    www.domain1.com /fr;
    www.domain2.com /nl;
    www.domain2.com /en;
    www.domain2.com /de;
    www.domain2.com /fr;
}

map $http_host $MAGE_RUN_CODE {
    www.domain1.com website1_storeview1;
    www.domain1.com website1_storeview2;
    www.domain1.com website1_storeview3;
    www.domain1.com website1_storeview4;
    www.domain2.com website2_storeview1;
    www.domain2.com website2_storeview2;
    www.domain2.com website2_storeview3;
    www.domain2.com website2_storeview4;
}

location ~ \.php$ {
    fastcgi_pass fpm:9000;
    fastcgi_intercept_errors on;
    include fastcgi_params;
    #fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    fastcgi_param DOCUMENT_ROOT $realpath_root;
    fastcgi_read_timeout 3600;
    fastcgi_param MAGE_RUN_TYPE website;
    fastcgi_param MAGE_RUN_CODE $MAGE_RUN_CODE;
    fastcgi_index index.php;
}

I am not an nginx expert but got my setup running in the end :)

1

Using subdirectorries

Add the Language directory as subdirectories symlinking the index.php to the original one. Then detect subdirectory + domain name in the index.php to set the active storecode.

  • He asked about nginx ;) – Anna Völkl Feb 28 '18 at 10:09
  • @AnnaVölkl oooops corrected that – Sander Mangel Feb 28 '18 at 10:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.