Magento Tutorial: Multi-Site, Multi-Domain Setup

Tutorial: Multi-Site, Multi-Domain Setup

One of Magento’s greatest strengths is its capabilities for scaling to support multi-store and multi-language retailing all from the same backend. In this tutorial, we will be showing you how to take advantage of Magento’s scalability by creating multiple websites with unique domain names sharing the same product catalog. (***NOTE: Each store can also be configured to offer a unique product catalog as well.

For this example, we’ll be attempting to set up domain1.comdomain2.com and domain3.com

Generally, Magento is installed into the folder /var/www/http, as per the Magento Installation Guide, and you can find more information related to the initial setup and configuration of any Magento installation there.  We aren’t going to through an full blown installation right now though, and for our purposes, we are going to presume that the Magento instance has already been installed in the server. 

We’ll be dividing the process into steps based on the areas of configuration we will need to deal with–namely, Categories, Store Configuration in Magento Admin, Store Configuration in the Server. 


1: Categories

 

First, will need to create our Categories.  Since all three websites will be sharing the same catalog, we will be using the default root Category in Catalog -> Categories -> Manage Categories and will be creating our categories under that root category (i.e. Clothing, Electronics, etc.). 

image 

These categories (Clothing, Electronics) should be set as both “Is Active” from the General Information tab and “Is Anchor” from the Display Settings tab for them to appear on the frontend of your Magento shop.  (***NOTE: If the websites will not be sharing the same catalog, a Root Category must be created for each website.  Thus, if there are 3 websites, there will be 3 Root Categories with subcategories under them.


2: Store Configuration in the Magento Admin

 

1. Now that we have created our Categories, it’s time to create our websites by going to System -> Manage Storesand clicking the “Create Website” button.


  • Name – domain name of our new website
  • Code – a parameter that will be used in configuring the Apache web server to point to that particular domain name

image 

2. Once the website has been created, we’ll create the store corresponding to this website by clicking on the “Create Store” button in System -> Manage Stores.

 

  • Website – website to which this store will be associated
  • Name – the same as the website name
  • Root Category – the root category that will be used for this store. (Refer to Step 1 for Details)

image 

3. Then, we create the store view which is the interface that the customer will be able to access on the frontend.  Click the “Create Store View” button in System -> Manage Stores


    • Store – store to which this view will be associated
    • Name – name of this store view (i.e. English Version, German Version, etc.)
    • Code – code for this store view
    • Status – if enabled, this store view will be accessible from our frontend, otherwise, it will not be accessible

image

4. After the Store has been created, we need to configure the Unsecure Base URL and Secure Base URL under System -> Configuration -> General -> Web.  Before we set their respective base URLs, we first need to ensure that the configuration scope is set to the domain1.com website to define which site we are working on.

image 

Then, we modify the base URLs for both Unsecure

image

and Secure

image

with the corresponding domain name by unchecking the ”Use default [STORE VIEW]” checkbox and then save the configuration. 

5. Now we just repeat Steps 2-4 for the other two websites, domain2.com and domain3.com by replacing the fields with their respective information. 


3: Store Configuration in the Server

 

1. Now we re-configure the Apache configuration file, httpd.conf, for all domains to set theDocumentRoot to our Magento directory.  In this case, the directory is /var/www/http


<VirtualHost *:80>
    ServerAdmin webmaster@domain1.com
    DocumentRoot /var/www/http
    ServerName domain0.com
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@domain2.com
    DocumentRoot /var/www/http
    ServerName domain1.com
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@domain3.com
    DocumentRoot /var/www/http
    ServerName domai2.com
</VirtualHost>

 


2. Edit the .htaccess file at /var/www/http/.htaccess and add the following lines below:


SetEnvIf Host www\.domain1\.com MAGE_RUN_CODE=domain1_com
SetEnvIf Host www\.domain1\.com MAGE_RUN_TYPE=website
SetEnvIf Host ^domain1\.com MAGE_RUN_CODE=domain1_com
SetEnvIf Host ^domain1\.com MAGE_RUN_TYPE=website

SetEnvIf Host www\.domain2\.com MAGE_RUN_CODE=domain2_com
SetEnvIf Host www\.domain2\.com MAGE_RUN_TYPE=website
SetEnvIf Host ^domain2\.com MAGE_RUN_CODE=domain2_com
SetEnvIf Host ^domain2\.com MAGE_RUN_TYPE=website

SetEnvIf Host www\.domain3\.com MAGE_RUN_CODE=domain3_com
SetEnvIf Host www\.domain3\.com MAGE_RUN_TYPE=website
SetEnvIf Host ^domain3\.com MAGE_RUN_CODE=domain3_com
SetEnvIf Host ^domain3\.com MAGE_RUN_TYPE=website

 


3. Restart Apache Server 

If you are on a Red Hat based distribution, you’ll be able to type service apache restart.  For other distributions, you’ll want to type apachectl restart.  (***NOTE: The second option here is different than “apachectl graceful” which will run a graceful restart and reload configuration files, without terminating current connections.  We don’t have any visitors to our site yet, so it’s okay to do a “apachectl restart”.)


4: We’re Ready to Go!

 

After we’ve complete all of these steps we should now see all 3 domains in our backend: 

image 

All that’s left now is to add products to the catalog and give each site a custom theme if we wish to do so.  Many people are taking advantage of Magento’s powerful multi-store functionality, whether it’s to set up stores with multiple languages, different catalogs and even the same catalogs (as in our example) with different front ends as a marketing vehicle.  No matter which you decide to use Magento’s powerful features for, we hope this post will provide a good starting point to help you get there!

Author Bio: This post is part of a series by the Magento Enterprise Edition subscription support team covering tips, tricks and hints to some of the most common, and uncommon, issues as submitted by support customers.



Or visit the following article: http://www.magentocommerce.com/knowledge-base/entry/tutorial-multi-site-multi-domain-setup

Have more questions? Submit a request

1 Comments

  • 0
    Avatar
    Jason Shico

    Overview: How Multiple Websites & Stores Work

    Global | Website | Store | Store View

    One of Magento’s advanced features allows for management of multiple websites and stores within one installation, and we have an amazing system to support this:  GWS - aka “Global, Website, Store.” 

    • Global: This refers to the entire installation.
    • Website: Websites are ‘parents’ of stores.  A website consists of one or more stores. Websites can be set up to share customer data, or not to share any data
    • Store (or store view group): Stores are ‘children’ of websites.  Products and Categories are managed on the store level.  A root category is configured for each store view group, allowing multiple stores under the same website to have totally different catalog structures.
    • Store View: A store needs one or more store views to be browse-able in the front-end.  The catalog structure per store view will always be the same, it simply allows for multiple presentations of the data in the front.  90% of implementations will likely use store views to allow customers to switch between 2 or more languages.

     

    image

     

     

    Example scenario

    Let’s say you want to sell appliances, consumer electronics, and DVD’s and CD’s.  For the purpose of this example we’ll separate the catalog into two stores and three websites.  The appliance line will be sold on its own website, and the remaining items on another website.  You bought appliances.com and coolstuff.com for this purpose.  You don’t want customer data and order data to be shared between the two websites, so data sharing will be turn off in the configuration between them.

    Under coolstuff.com you create two stores - Electronics, and Media.  Consumer electronics will be sold through the electronics store, and the media items through the Media store.  Since each line of items is very extensive, it makes sense to create a separate category structure for the Media store and the Electronics store… otherwise the category tree would be large and cumbersome.  When the stores are created, you simply assign a different root category to each store.

    In addition, you want to feature your catalog for both websites in English and Spanish.  To do this, you will create an English and Spanish store view for each of the three stores.  When entering catalog data you can switch store views in the admin to create the additional product titles, descriptions etc…

    Configuration

    The configuration of Magento uses GWS as a kind of tree when setting up the stores.  When it is initially installed, all configuration settings point to “default”, meaning the global installation.  A check box next to each configurable item can be un-checked in a particular website or store view, to indicate that this item will be specific to this website or store view.  For example, you will offer authorize.net as a payment module on both websites, but you only want to offer google checkout on coolstuff.com.  In the configuration, you’d select coolstuff.com in the store view drop-down, find the google API settings, and un-check “use default” in the google checkout tab.  For this specific website you can now enable or disable google checkout.

    All modules in the configuration function the same way.

    Moving on to store views - after a store view has been created, you can configure the layout and visual settings of the store view however you’d like - a drop-down allows customers to switch between store views.  This will reload the current page with the alternate view.  This can be used for multiple languages, but can also be a way to easily do A-B testing between several design packages to see if one yields more conversions.  The possibilities are endless!

    The above is meant as a basic overview of this functionality - the best way to learn how to set it all up is to install Magento and get in there and start playing around.

    I also created two short videos that go into a little more detail regarding the configuration.  Enjoy! 

    Video: Creating Multiple Online Storefronts, Part 1 

    Video: Creating Multiple Online Storefronts, Part 2 

     

Please sign in to leave a comment.
Powered by Zendesk