The Most Popular Extension Builder for Magento 2

With a big catalog of 224+ extensions for your online store

How to Setup Multi Store in Magento 2

Setting up Magento Multi Store is one of the variable functionalities Magento 2 brings to store owners. This feature allows you to create stores as many as you need only in a single configuration. All stores share the same domain, be set up as subdomains of the same domain, or have an entirely different domain, yet possibly share the same backend for easier administration.

Learn more: Setup automatic change store view using Magento 2 Store Switcher

Benefits of creating multiple stores in Magento 2

With different goals in mind, such as expanding your business or operating your business in different locations, you may want to create multiple stores. But multiple stores can bring you more amazing outcomes than that, such as:

  • Save money by using the same payment gateways
  • Get uniform support for all of your built stores from third-party extensions
  • Maintain a standard customer database that may be used across all stores.
  • Share the same content of Terms & conditions, privacy policy, and other materials for the pages.

Therefore, you can follow the instructions below to apply these awesome benefits to your store. Additionally, you can add multiple websites for each store you want to configure.

7 Steps to Setup Multiple Stores in Magento 2

Step 1: Create Websites

Go to Store > Settings > All Stores. Then, click on Create Website, and fill out the following fields:

Create a new website

  • Name: Insert a name for your new website.
  • Code: This code needs to be unique.
  • Sort Order (Optional): Insert the sort order for your website. Remember, the default is ‘0’.

Website's fields

Step 2: Create Stores

In this step, you will fill in the required information about the new store in the ‘Store Information’ section.

  • On the Admin Panel, Stores > Settings > All Stores.
  • Click on Create Store, then follow the below
    • Select the Website that is the parent of the new store. If there is only one website, use the default “Main Website”.
    • Fill in the Name for the new store, just for internal reference.
    • In the Root Category field, you will set the root category for the main menu of the new store. The created root categories are shown in the dropdown list, select one for the store.

How to Setup Multiple Stores Magento 2 Information

  • Save Store to complete.

How to Setup Multiple Stores New Stores

Step 3: Add Store Views

After adding the new store, you will now need to create the store view:

  • Click on Create Store View, you can:
    • Assign the Store to the new store you’ve just created.
    • Set the Name for the store view.
    • Type the Code for the store view with lower characters.
    • Choose “Enabled” for the Status.
    • Specify the Sort Order that is the position of the new store in the list.
  • Save Store View to save all settings.

How to Setup Multiple Stores Magento 2 View Information

Step 4: Setup the Website’s Base URL

In this step, we will configure the Store URL.

  • On the Admin Panel, go to Stores > Settings > Configuration.
  • On the left panel, under General, select Web.
  • In the upper-left corner, choose Store View to check the new store you added.
  • Hit OK to verify the scope switching.

How to Setup Multiple Stores Magento 2 Choose New Store View

  • Open the Base URLs section,
    • Clear the Use Website checkbox, that is next to the Base URL field.
    • Change the Base URL for the store.

How to Setup Multiple Stores Base URLs

  • Open the Secure Base URLs section below to set the store’s secure URL if needed.
  • Save Config to complete.

Step 5: Add the store code to the base URL

With Magento, admins can add a store code to the website’s base URL, simplifying the multistore setup process. Thanks to this feature, store owners can cut down the step of creating directories on the file system for storing index.php and .htaccess.

Additionally, this option helps prevent index.php and .htaccess from falling out of sync with the Magento source in future upgrades.

  • Go to the admin panel and navigate to Stores > Settings > Configuration.
  • Under the General section, choose Web.
  • From the list at the top, select Default Config.
  • Then you will see the first section - Url Options, fill it out.

URL

Step 6: Change the base URL in the default store view

  • Navigate to Stores > Settings > Configuration. Under the General section, choose Web.
  • From the list at the top, select Default Config.
  • Then, expand the Base URLs section and insert your website’s base URL.
  • Ex: https://www.example.com/
  • Finally, click the Save Config button.

Note: You might be confused that your access to the admin panel is no longer active after this step. Don’t panic, it will be accessible again soon after you finish the next step - configuring virtual hosts.

Step 7: Server-side configurations

This is the final step to complete setting up Magento 2 multistore. At this point, store admins need to change a few things to the web server configuration. In detail:

  • For each new website, create a new virtual host.
  • Pass the MAGE_RUN_TYPE and MAGE_RUN_CODE values to the new configurations.
  • Configure static routes to the host (Optional)

Depending on the type of server you run, the process of creating a new virtual host for your new websites may differ.

Ex: With Apache 2.4 and above servers, the process requires modifying your /etc/httpd/conf/httpd.conf likethis:

<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>
  • ServerName: your new website’s domain.
  • DocumentRoot: where Magento is enabled. It’s highly recommended to set DocumentRoot to Magento /pub/ directory for better security.
  • SetEnv MAGE_RUN_TYPE: set to website or store, based on the ServerName: a new website/ a new store scope.
  • SetEnv MAGE_RUN_CODE: configure to the unique website/ store view code corresponding to MAGE_RUN_TYPE.

After that, restart the web server by running:

  • CentOS: service httpd restart
  • Ubuntu: service apache2 restart

Configure static routes to the host (Optional)

If you don’t have DNS configured for your store’s URLs, create static routes in the hosts file, following this format:

<ip address> <new website>

Note: If you want a separate checkout procedure, configure your Magento domains to use different IP addresses. That’s it! Your multi-stores are now ready.

FAQs

1. Can I use different themes for each store in Magento 2?

Yes, in Magento 2, you can use different themes for each store. This feature allows you to customize the appearance of each store independently to suit its branding or target audience. You can assign specific themes to individual stores or store views within your Magento 2 installation. This flexibility enables you to create unique and tailored experiences for customers visiting different stores under the same Magento 2 instance.

2. Is it possible to manage different settings for each store within Magento 2?

In Magento 2, you can handle separate settings for each store. You can adjust Magento settings and set different “website base URLs” for each store. This allows you to customize settings such as prices, products, and themes according to your needs.

3. Can you have several store views with different base URLs in Magento?

In Magento, you can make various store views with separate base URLs. This lets you customize the web server setup for each store view, guaranteeing each store has its distinct online identity.

4. How can I configure Magento for multiple storefronts?

To set up Magento for multiple stores, you can give each store its own web address. Make sure each new website has a designated host. Also, give each store a unique code to tell them apart. You can create as many stores as you want, each with multiple web addresses for better organization.

The bottom line

The need to set up Magento multi store has been increasing due to different business goals, and also because of the amazing benefits it can bring to online stores. If you also want to do it, start following this tutorial. Leave comments below to share your ideas and tell us about your concerns if any. See you in later posts!

Related Post

Looking for
Customization & Development Services?

8+ years of experiences in e-commerce & Magento has prepared us for any challenges, so that we can lead you to your success.

Get free consultant
development service
x

    Explore Our Products:

    People also searched for

    Subscribe

    Stay in the know

    Get special offers on the latest news from Mageplaza.

    Earn $10 in reward now!

    Earn $10 in reward now!

    comment
    iphone
    go up