0

I have magento instance running on 8090 port. I have created an another store call store2 I followed all the steps and also change base url and added store code with base url as per this link

My virtual host file is below.

<VirtualHost *:80>


        ServerName http://192.168.1.179:8090/

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

 <VirtualHost *:80>
    ServerName          http://192.168.1.179:8090/store2/
    DocumentRoot        /var/www/html/
    SetEnv MAGE_RUN_CODE "store2"
    SetEnv MAGE_RUN_TYPE "website"
 </VirtualHost>

My index.php is below.

<?php

try {
    require __DIR__ . '/app/bootstrap.php';
} catch (\Exception $e) {
    echo <<<HTML
<div style="font:12px/1.35em arial, helvetica, sans-serif;">
    <div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;">
        <h3 style="margin:0;font-size:1.7em;font-weight:normal;text-transform:none;text-align:left;color:#2f2f2f;">
        Autoload error</h3>
    </div>
    <p>{$e->getMessage()}</p>
</div>
HTML;
    exit(1);
}

$params = $_SERVER;
$customstore = array(
    'http://192.168.1.179:8090/store2'=>'store2' // Website, Store or Storeview Code

    );
if(isset($customstore[$_SERVER['HTTP_HOST']]))
    $websitecode = $customstore[$_SERVER['HTTP_HOST']];
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = isset($websitecode) ? $websitecode : '';
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website';//use website or store or view 
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
$app = $bootstrap->createApplication('Magento\Framework\App\Http');
$bootstrap->run($app);

but my http://192.168.1.179:8090/store2 returns 404 error.

0

I would create a new directory for store2 and copy the .htaccess and index.php into that new directory. Then update /store2/index.php to set the website code and update the line require __DIR__ . '/../../app/bootstrap.php'; to go up one directory. This way when you hit http://192.168.1.179:8090/store2 it will start at your new directory and index.php file. You can also symlink media, static, errors, etc from your store2 directory back to your /var/html/www media, static, and error directories. I believe you will also need to update your DocumentRoot in your virtual host from your example above.

Also, if you don't have a home page specified for the new store view it will display a 404 as well.

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.