Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zeloc/760046dee16e6f2d0d51a3d5c9fd58df to your computer and use it in GitHub Desktop.
Save zeloc/760046dee16e6f2d0d51a3d5c9fd58df to your computer and use it in GitHub Desktop.
Configure Multiple Magento2 Websites or Stores with Nginx
#etc/nginx/sites-available
map $http_host $MAGE_RUN_CODE {
ecc-m234-s1.vm ubs_view;
}
server {
listen 80;
server_name mystore.com mystore.de mystore.es;
set $MAGE_ROOT /path/to/your/magento2;
set $MAGE_MODE default;
include /path/to/your/magento2/nginx.conf.sample;
}
#path/to/magento/nginx.conf.sample
#...
# PHP entry point for main application
location ~ (index|get|static|report|404|503)\.php$ {
try_files $uri =404;
fastcgi_pass fastcgi_backend;
fastcgi_buffers 1024 4k;
fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
fastcgi_param PHP_VALUE "memory_limit=768M \n max_execution_time=600";
fastcgi_read_timeout 600s;
fastcgi_connect_timeout 600s;
#add here - start
fastcgi_param MAGE_RUN_TYPE store;
fastcgi_param MAGE_RUN_CODE $MAGE_RUN_CODE;
#end
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#...
@zeloc
Copy link
Author

zeloc commented Jan 4, 2021

When setting the above information:

    mystore.com mystore_en;
    mystore.de mystore_de;
    mystore.es mystore_es;
}

the store code refers to the store view code

Steps:

  1. create store/website in magento
  2. Note the store view code
  3. update the nginx file with the 2 areas indicated:
    map section and section at line 34
  4. You don't need to add the default store to the map section
  5. Make sure host file is updated with the new site url
  6. Restart Nginx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment