Thursday, May 4, 2017

MultiSite Configuration

Created multi website in magento, Steps to create a multistore in admin panel is same as like in magento1.x. Don't forget to change the base url and secure url for new website/store. Once made changes in admin panel follow the below steps,
1) Create a new folder in magento root and copy the index.php and .htaccess files from magento root to new folder.
2) Edit the index.php which is in new folder
Replace:
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);

/** @var \Magento\Framework\App\Http $app */

$app = $bootstrap->createApplication('Magento\Framework\App\Http');

$bootstrap->run($app);
With:
 $params = $_SERVER;

 $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'newstore'; //Webite code as same in admin panel

 $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');

 $bootstrap->run($app);
3) Create a simlinks inside the new folder
 ln -s /home/example/example.com/html/app/ app 

 ln -s /home/example/example.com/html/lib/ lib 

 ln -s /home/example/example.com/html/pub/ pub 

 ln -s /home/example/example.com/html/var/ var 
Refer this
Please clear the var/generation,var/cache and pub/static files and do the static content deployment.