I am trying to create multi websites in Magento 2 in local environment with XAMPP on Windows operating system 10.
I followed this tutorial : http://devdocs.magento.com/guides/v2.0/config-guide/multi-site/ms_apache.html.
Created multi websites in the admin, changed the base url of each website in the configuration (Stores->Configuration->Web) and specified the virtual hosts in the file C:\xampp2\apache\conf\extra\httpd-vhosts.conf like below attached screenshot Screenshot of Apache Virtual Host configuration file
Then specified the base URLs in the host file like follows:
127.0.0.1 french.mysite.mg
127.0.0.1 german.mysite.mg
I restarted the Apache server but none of the created websites are loading. Can you please correct me if I am missing anything?
-
Have you found any solutions on how to setup multisite on xamp?chirag dodia– chirag dodia2017年07月11日 10:42:45 +00:00Commented Jul 11, 2017 at 10:42
-
Did you edit your host file properly?gabehou– gabehou2017年10月25日 16:16:28 +00:00Commented Oct 25, 2017 at 16:16
-
magento.stackexchange.com/questions/94855/… try thisRavindrasinh Zala– Ravindrasinh Zala2017年12月29日 07:02:28 +00:00Commented Dec 29, 2017 at 7:02
5 Answers 5
The reason depends on result you receive trying open website on Store Front.
- Store Front opened with error (5xx, 404) - something with your apache configuration, maybe virtual hosts file is not being read. Check apache access and error logs, it can helps identify the problem.
- Store Front always redirect to base site (mysite.mg) - probably you forget to clean cache
I can't reproduce this case on latest develop branch.
It is important to know Magento version to be able check it as well.
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] = 'website2'; //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);
And also update bootstrap.php include path as below,
Replace:
require __DIR__ . '/app/bootstrap.php';
With:
require __DIR__ . '/../app/bootstrap.php';
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.
Okay, i was stuck in your situation just like you, and after few time looking on Google, i've found the answer, only need to clear cache in your project, that's all.
For some one who looking to create virtual host in magento 2, i will put it here:
In C:\xampp\apache\conf\extra\httpd-vhosts.conf put this:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/magento"
ServerName fudu.magento.net
</VirtualHost>
In C:\Windows\System32\drivers\etc\hosts put this:
127.0.0.1 fudu.magento.net
With fudu.magento.net is your virtual domain, and DocumentRoot "C:/xampp/htdocs/magento" is your project folder.
There are 6 steps to implement multiple website or store on the Magento2 site.
Step 1: Create a Root Category
Step 2: Create a new website
Step 3: Create a new store
Step 4: Create store views
Step 5: Configure the Store URL
Step 6: Map the vhost to work with Magento 2
-
can you make a video about multiwebsite virtul host setup?Afzel Arshad– Afzel Arshad2024年02月14日 12:43:56 +00:00Commented Feb 14, 2024 at 12:43
if you are using nginx server you need to follow below steps Add This Entray on below files
sudo nano /etc/nginx/fastcgi_params
# Magento Variables
fastcgi_param MAGE_RUN_TYPE $MAGE_RUN_TYPE;
fastcgi_param MAGE_RUN_CODE $MAGE_RUN_CODE;
fastcgi_param MAGE_MODE $MAGE_MODE;
HostEntray
=====
server {
listen 80;
listen 443 ssl;
include snippets/ssl-cert.conf;
server_name local.magento245.com;
client_max_body_size 32M;
set $MAGE_ROOT /var/www/html/magento2/magento245;
set $MAGE_RUN_TYPE website;
set $MAGE_RUN_CODE fr;
set $MAGE_MODE developer;
#set $MAGE_MODE default;
#set $MAGE_MODE production;
fastcgi_read_timeout 3000;
}
Explore related questions
See similar questions with these tags.