How to setup multiple stores on different domains with Magento

If you enjoyed this article, please leave a comment, rss subscribe to my RSS feed and/or follow me on Twitter. Thank you very much!

Multiple stores is probably the killer feature of the Magento Commerce store. It enables the needy to manage multiple stores through a single interface. Your very own mall in a box.

It's also a management/deployment nightmaredream come true. A single piece of software powering multiple websites.

This small HowTo requires a working installation of Magento (tested with Magento Commerce v1.3), multiple stores setup already, an understanding of your (web)server, some shell-fu and probably root access.

I won't go into creating virtual hosts, and if you're stuck with CPanel, Plesk or similar, this may work as well but I can't help you very much.

Making it work

Magento is complex and so on, but let's disregard the caveats for now and figure out how to make it run.

This setup is one of the things that took me a good while to research, so I'm sharing this so it jump starts others. I remember I had a wiki or knowledge base entry over at Magento bookmarked, but that one seemed to have vanished.

My file system layout is as follows:

/web/customer/magento/1.3/

/web/customer/magento/1.0/

/web/customer/example.org/htdocs

/web/customer/example.net/htdocs

Now, let's say you have a store setup for example.org and one setup for example.net, then place an index.php with the following contents in each htdocs directory:

<?php
require_once '/web/customer/magento/1.3/app/Mage.php';
Mage::run('STORE-CODE', 'store');

The STORE-CODE is hidden in your Magento Commerce Admin. Go to System > Configuration and then click on the designated Store View.

Last, but not least — add the following symbolic links inside both htdocs directories:

ln -s ../../magento/1.3/app/ ./app
ln -s ../../magento/1.3/downloader ./downloader
ln -s ../../magento/1.3/js/ ./js
ln -s ../../magento/1.3/media/ ./media
ln -s ../../magento/1.3/skin/ ./skin
ln -s ../../magento/1.3/var/ ./var

Of course you may need to adjust the paths around, but aside from that, it's all straight forward.

And that is all!

Update: Updated instructions for symlinking (added downloader).

| More