Follow this and comment for any issue:
- Verify your desired domain name points to the server.
- Create a secondary domain for your new store.
- Using either FTP or SSH, copy the .htaccess and index.php files from your Magento installation to the document root of your new domain.
- Open the index.php file that you just copied and edit the last lines of the file as follows:
Attention: Change newstore to the code that you wrote down when you created the new website above.
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:
require __DIR__ . '/app/bootstrap.php';
$params = $_SERVER;
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'newstore';
$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);
- Using SSH, create the following symbolic links in the document root of your new domain, and replace the path below with the full path to the document root of your Magento Installation:
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
Update in Your case:
Replace ln -s /home/example/example.com/html/app/ app
with ln -s /var/www/html/m2/example.com/app/ app