We assume that:
If necessary, copy the existing
index.php entry point script for your website or store view and add to it the following:
You are working on a development machine (laptop, virtual machine, and so on)
Additional tasks might be required to deploy multiple websites in a hosted environment; check with your hosting provider for more information.
Additional tasks are required to set up Adobe Commerce on cloud infrastructure. After you complete the tasks discussed in this topic, see Set up multiple websites or stores in the Commerce on Cloud Infrastructure guide.
You use one virtual host per website; the virtual host configuration file is
Different versions of Apache on different operating systems set up virtual hosts differently. Consult the Apache documentation or a network administrator if you are not sure how to set up a virtual host.
The Commerce software is installed in
You have two websites other than the default:
french.mysite.mgwith website code
frenchand store view code
german.mysite.mgwith website code
germanand store view code
Setting up multiple stores consists of the following tasks:
This section discusses how to set values for
MAGE_RUN_CODE using the Apache server variable
SetEnvIf in a virtual host.
For more information about
To create Apache virtual hosts:
As a user with
root privileges, open the virtual host configuration file in a text editor.
For example, open
Locate the section starting with
Create the following virtual hosts after any existing virtual hosts:
<VirtualHost *:80> ServerName mysite.mg DocumentRoot /var/www/html/magento2/pub/ </VirtualHost> <VirtualHost *:80> ServerName french.mysite.mg DocumentRoot /var/www/html/magento2/pub/ SetEnv MAGE_RUN_CODE "french" SetEnv MAGE_RUN_TYPE "website" </VirtualHost> <VirtualHost *:80> ServerName german.mysite.mg DocumentRoot /var/www/html/magento2/pub/ SetEnv MAGE_RUN_CODE "german" SetEnv MAGE_RUN_TYPE "website" </VirtualHost>
Save your changes to
httpd.conf and exit the text editor.
service httpd restart
service apache2 restart
Unless you have DNS set up for your stores’ URLs, you must add a static route to the host in your
Locate your operating system
Add the static route in the format:
<ip-address> french.mysite.mg <ip-address> german.mysite.mg
Go to one of the following URLs in your browser:
http://mysite.mg/admin http://french.mysite.mg/frenchstoreview http://german.mysite.mg/germanstoreview