Magento -- steps for implementing multiple domain names and multiple online stores

Source: Internet
Author: User
Tags addon domain cpanel magento admin ssl certificate shared hosting subdomain wildcard ssl wildcard ssl certificate

 

Http://www.crucialwebhost.com/blog/how-to-setup-multiple-magento-stores/#addon-domain-method

Address Source

 

 

How to setup multiple magento stores

By Kyle on December 28,200 8. posted in howto, magento · 78 comments

There are numerous ways to setup multiple magento stores that all share the same codebase and backend, But what method you use depends on your needs.

This article is written with cpanel in mind, though the methodologies listed below apply no matter what control panel you're using.

Jump to Section
  1. URL Structure
  2. Shared hosting Caveat
  3. Adding another store in magento
  4. Parked Domain Method
  5. Addon Domain Method
  6. Subdomain Method
  7. Subdirectory Method
  8. Managing multiple stores
  9. Secure checkout for each domain
URL Structure

The actual URL structure of your stores is a matter of personal preference. You can, for example, have two entirely different stores running on the same domain that share the same instance of magento:

  • mall.com/shoes
  • mall.com/shirts

These stores cocould also be setup on their own domain and still share the same instance of magento:

  • shoes.com
  • shirts.com

Another example wocould be a mall type setup, where your primary domain is the portal to access varous stores:

  • mall.com
  • shoes.mall.com
  • shirts.mall.com

Regardless of the URL structure, the method for setting this up will be pretty much be the same, and the result is what we're really after, which is to have one codebase for all of your stores, and one backend to manage all of these stores from.

Shared hosting Caveat

If you want each store to have it's own SSL Certificate and don't want to share a single checkout, e.g. You don't want visitors leavingdomainA.comTo checkout ondomainB.com, Then you will not be able to do this in a shared hosting environment.

The reason why you cannot do this is simple. In order for a website to have an SSL certificate, it requires a dedicated IP address.

There's no way to allow an addon or parked domain in cpanel to have its own IP address. Instead, it shares the IP address of the primary domain.

You probably think you cocould sign up for two shared hosting accounts, so each one has its own dedicated IP address, but that won't work either.

Since it's shared hosting, there are security measures in place to prevent one user from reading the files of another user.

So for shared hosting clients, you're limited to the following scenarios:

  1. All of your stores do not have a secure checkout, which is fine if you're using PayPal, Google Checkout, or a similar third-party service that handles the processing of card data on their website. for example, visitors to any of your stores are redirected to a third-party website for card processing.
  2. All of your stores share a secure checkout point. for example, you own three domains: mall.com, shoes.com, and shirts.com you use mall.com as your primary domain and have an SSL Certificate associated with it. the other two domains wocould be either addon or parked domains, and visitors to those sites wocould be redirected to mall.com to checkout.
  3. All of your stores are setup as subdomains, And you 've purchased a wildcard SSL certificate, which is roughly $1000/year and is for legally registered businesses.

If you do need an SSL certificate for all of your domains, you will need to be in a dedicated hosting environment, such as our split-dedicated platform. in this type of environment, all domains will be able to access the same set of files.

Adding another store in magento

The first thing we need to do is setup our second store in magento.

If you don't know how to install magento, read our tutorial or submit a ticket to the magento department.

We're re going to do a hypothetical here for the naming conventions, and assume we ownshirts.com. Adjust the values accordingly for your own store.

  1. Login to the magento admin.
  2. Go toCatalogTab, and selectManage categories.
  3. Click onAdd root categoryButton on the left.
  4. On the right, forName, We'll enterShoes.com. Set the dropdownYesFor bothIs ActiveAndIs anchor.
  5. ClickSave categoryButton.
  6. Go toSystemTab and selectManage stores.
  7. Click onCreate websiteButton.
  8. ForName, We'll enterShoes.com, And forCode, We'll entershoes. We'll use this value later, so don't forget this!
  9. ClickSave websiteButton.
  10. Click onCreate storeButton.
  11. ForWebsite, SelectShoes.comFrom the dropdown. ForName, We'll enterMain Store. ForRoot category, SelectShoes.comFrom the dropdown.
  12. Click onSave storeButton.
  13. Click onCreate Store ViewButton.
  14. ForStore, SelectMain StoreFrom the dropdown, making sure it's forShoes.comWebsite. ForName, We'll enterEnglish. ForCode, We'll entershoes_en. ForStatus, SelectEnabledFrom the dropdown.
  15. ClickSave Store ViewButton.
  16. Go toSystemTab and selectConfiguration.
  17. ForCurrent configuration Scope(Located on the top left), change the dropdown menu from Default ConfigToShoes.com.
  18. SelectWebFrom the sidebar on the left underGeneralHeading.
  19. For bothUnsecureAndSecureSections, uncheckUse defaultBox next toBase URLItem, and enter the URL for your store, e.g. http://www.shoes.com/. Don't forget the trailing slash!
  20. ClickSave configButton.

Now that we have our second store setup, you'll need to choose one of the following methods for actually setting up the store on the server-side so visitors can access it.

If the URL structure you 've chosen will have different domains for each store, the parked domain method is the fastest and easiest method.

Parked Domain Method

For this method, we'll pretend we ownshirts.comAndshoes.com.shirts.comDomain is our primary domain, and magento is already installed on it. Here's how we wocould set this up forshoes.comDomain:

  1. Login to cpanel for your domain and click onParked DomainsIcon.
  2. In the input field, enter the domain name that you'll be setting up as a second store, e.g.shoes.com.
  3. Click onAdd domainButton.
  4. Open upindex.phpFile for magento and replace the last line of code:
    Mage::run();

    ... With the following code:

    switch($_SERVER['HTTP_HOST']) {case 'shoes.com':case 'www.shoes.com':Mage::run('shoes', 'website');break;default:Mage::run();break;}

    If you have more than two stores, you will need to add additional cases to the above code block, e.g .:

    switch($_SERVER['HTTP_HOST']) { // Shoes.comcase 'shoes.com':case 'www.shoes.com':Mage::run('shoes', 'website');break; // Hats.comcase 'hats.com':case 'www.hats.com':Mage::run('hats', 'website');break; // Shirts.com (default store)default:Mage::run();break;}
Addon Domain Method

This is the same scenario as abve, doesn't it takes a little longer to setup. this method might be more useful to you if, for example, you wanted to have a blog on one domain, but not on the other. you couldn't do that with a parked domain. here's how we wocould set this up forshoes.comDomain:

  1. Login to cpanel for your domain, and click onAddon DomainsIcon.
  2. ForNew Domain Name, We'll entershoes.com. Cpanel will automatically fill in the next two fields, so removepublic_html/FromDocument RootField, leaving us with justshoes.com. This step isn' t required, but for organizational purposes, it makes more sense.
  3. Set a password for this domain and click onAdd domainButton.
  4. Login to your site via SSH, and go to the directory that we previusly set inDocument RootField Above when adding our domain. In our case, we wocould do the following:
    cd shoes.com/
  5. Copyindex.phpAnd.htaccessFile from the directory where magento is installed, which wocould be in our root web directory:
    cp ../public_html/index.php ../public_html/.htaccess .
  6. Open upindex.phpFile that we just copied over and replace the following line of code:
    $mageFilename = 'app/Mage.php';

    ... With the following:

    $mageFilename = '../public_html/app/Mage.php';
  7. Withindex.phpFile still open, replace the following line of code:
    Mage::run();

    ... With the following:

    Mage::run('shoes', 'website');
  8. Lastly, we need to create symbolic links to point to a few directories:
    ln -s ../public_html/404/ ./404ln -s ../public_html/app/ ./appln -s ../public_html/includes/ ./includesln -s ../public_html/js/ ./jsln -s ../public_html/media/ ./medialn -s ../public_html/report/ ./reportln -s ../public_html/skin/ ./skinln -s ../public_html/var/ ./var
Subdomain Method

For this method, we'll pretend we ownmall.com, And it's setup as a portal that links to the varous shops within the mall. magento will be installed onmall.comDomain, and all of the shops will be in subdomains, e.g .:

  • shoes.mall.com
  • shirts.mall.com

Here's how we wocould set this up forshoesSubdomain:

  1. Login to cpanel for your domain, and click onSubdomainsIcon.
  2. ForSubdomain, We'll entershoes. Cpanel will automatically fill in the next field, so removepublic_html/FromDocument RootField, leaving us with justshoes. This step isn' t required, but for organizational purposes, it makes more sense.
  3. ClickCreateButton.
  4. Login to your site via SSH, and go to the directory that we previusly set inDocument RootField Above when creating our subdomain. In our case, we wocould do the following:
    cd shoes/
  5. Copyindex.phpAnd.htaccessFile from the directory where magento is installed, which wocould be in our root web directory:
    cp ../public_html/index.php ../public_html/.htaccess .
  6. Open upindex.phpFile that we just copied over and replace the following line of code:
    $mageFilename = 'app/Mage.php';

    ... With the following:

    $mageFilename = '../public_html/app/Mage.php';
  7. Withindex.phpFile still open, replace the following line of code:
    Mage::run();

    ... With the following:

    Mage::run('shoes', 'website');
  8. Lastly, we need to create symbolic links to point to a few directories:
    ln -s ../public_html/404/ ./404ln -s ../public_html/app/ ./appln -s ../public_html/includes/ ./includesln -s ../public_html/js/ ./jsln -s ../public_html/media/ ./medialn -s ../public_html/report/ ./reportln -s ../public_html/skin/ ./skinln -s ../public_html/var/ ./var
Subdirectory Method

This is the same scenario as abve, should t all of the shops will be in subdirectories, e.g .:

  • mall.com/shoes
  • mall.com/shirts

Here's how we wocould set this up forshoesSubdirectory:

  1. Login to your site via SSH, and create a subdirectory where your second store will be:

    cd public_htmlmkdir shoes/cd shoes/
  2. Copyindex.phpAnd.htaccessFile from the directory where magento is installed, which wocould be in our root web directory:
    cp ../public_html/index.php ../public_html/.htaccess .
  3. Open upindex.phpFile that we just copied over and replace the following line of code:
    $mageFilename = 'app/Mage.php';

    ... With the following:

    $mageFilename = '../public_html/app/Mage.php';
  4. Withindex.phpFile still open, replace the following line of code:
    Mage::run();

    ... With the following:

    Mage::run('shoes', 'website');
Managing multiple stores

It's very important to remember that now that you have multiple stores to manage from one admin panel, that you make sure you're changing the configuration for the appropriate store.

InSystemConfigurationSection, if you leave the dropdown menuCurrent configuration ScopeSet Default Config, It will globally change the values for all of your stores, assuming you haven't removed the checkmark nextUse defaultThroughout the configuration sections.

You can change the configuration values globally, for each website, and for individual store views.

Secure checkout for each store

For those of you in Dedicated hosting environments, you can follow either the addon or parked domain method from above, and edithttpd.confFile to give the addon or parked domain a dedicated IP address.

However, this is not advised. Your changes will most likely be overwritten with a control panel upgrade, Apache or PHP rebuild, or even simple maintenance.

Your best bet wocould be to setup each store as a separate account, which can be done in whm if you have access to it, or in the case of our split-dedicated product, something we will be able to set up for you.

Once you have all of your domains setup as individual accounts, you wocould Follow Steps 5-8 for the addon domain method, should t you're going to use absolute paths instead of relative paths, e.g.:

$mageFilename = '/home/username/public_html/app/Mage.php';

... And for symbolic links:

ln -s /home/username/public_html/404/ ./404ln -s /home/username/public_html/app/ ./appln -s /home/username/public_html/includes/ ./includesln -s /home/username/public_html/js/ ./jsln -s /home/username/public_html/media/ ./medialn -s /home/username/public_html/report/ ./reportln -s /home/username/public_html/skin/ ./skinln -s /home/username/public_html/var/ ./var

Lastly, in order for the above to work, you will need suexec disabled. this won't be a problem in a dedicated hosting environment, since you don't have to worry about other people being able to access your files.

This is just one of the latest advantages of running your online business in a more secure and flexible hosting environment like this. if you're on our split-dedicated product, this is something we'll have to disable for you.

Once you 've done the above, all of your stores will have their own secure checkout and IP address, but will still share the same codebase and backend for management purposes.

Updatesmulti-store setup for 1.4.x

Please refer to the following blog post for changes on setting this up on the 1.4.x version of magento:

Http://cwhurl.com/mmss

Wildcard SSL Certificate

If you're having trouble installing a wildcard SSL Certificate with cpanel and setting it up on all your subdomains, please refer to Knowledge Base Article for help.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.