I want to create multistore website in magento2 for this my current system configuration is as follows-

  • Web server: Nginx
  • Magento Version: magento2.1.0
  • Cento OS Version: 7

for this I have followed below steps:

  1. Created Website/Store/View in magento2 admin.

  2. Added below code in pub/index.php

    $params[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS] = [
            DirectoryList::PUB => [DirectoryList::URL_PATH => ''],
            DirectoryList::MEDIA => [DirectoryList::URL_PATH => 'media'],
            DirectoryList::STATIC_VIEW => [DirectoryList::URL_PATH => 'static'],
            DirectoryList::UPLOAD => [DirectoryList::URL_PATH => 'media/upload'],
        switch($_SERVER['HTTP_HOST']) {
            case 'electronics-dev.local':
            case 'www.electronics-dev.local':
                $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'electronics';
                $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website';
            case 'magento2-dev.local':
            case 'www.magento2-dev.local':
                $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'base';
                $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website';
        $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
        /** @var \Magento\Framework\App\Http $app */
        $app = $bootstrap->createApplication('Magento\Framework\App\Http');

To create websites and stores:

  • Log in to the Magento Admin as a user authorized to create websites, stores, and store views.
  • Click Stores > All Stores.
  • To create a website, click Create Website.
  • To create a store, click Create Store.
  • To create a store view, click Create Store View.
  • When you create your website or store view, make note of its unique identifier because you’ll use it later.

For more information http://devdocs.magento.com/guides/v2.1/config-guide/multi-site/ms_over.html


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.