Multiple Magento Stores on the Same Server

In this tutorial we will be discussing how to set up multiple Magento stores on the same dedicated server. In this example I will be setting up 2 stores, one main store (TV Mania) and one sub-store (Macs R Us), both of these have been completely made up!

Create Root Category

Firstly we will need to create hosting accounts for each of the stores on the server and install Magento onto the main/parent account (TV Mania). Once we have installed Magento and have full access to the admin area we’ll need to create a new root category for our sub store (Macs R Us) to use.

We can do this by going to Catalog > Manage Categories and clicking Add New Root Category on the left. This will load the normal Magento category fields, in this example we will input the following and save the root category:

  • Name: Macs R Us Root
  • Is Active: Yes
  • Is Anchor: Yes

Create Website

Now we’ll need to configure the sub store and begin to make it manageable using the Magento admin area.

To do this we’ll need to go to System > Manage Stores and click the Create Website button on the right. Following the example above we will enter the following:

  • Name: Macs R Us
  • Code: macsrus

Click Save Website and make a note of the code as we will need this later on when we come to reference this store in the server side configuration.

Create Store

This will return us to the Manage Stores homepage, click the Create Store button and enter the following:

  • Website: Select the website we created in the last step, Macs R Us
  • Name: Macs R Us Store
  • Root Category: select the root category we created earlier (Macs R Us Root) and click save.

Create Store View

Again this will return us to the Manage Stores homepage, click the Create Store View button and enter the following:

  • Store: Select the store view we created in the last step, Macs R Us Store
  • Name: Macs R Us View
  • Code: macsrus_view
  • Enabled: Switch to Yes and save the store view.

Change Base URL

Now we will need to change the URL of the sub shop to do this we will need to go to System > Configuration and switch the Current Configuration Scope in the top left from Default Config to Macs R Us. Then select Web from the left sidebar under the General heading.

Under the Unsecure and Secure sections deselect the Use default checkboxes next to the Base URL fields and change them to the new URL and click Save Config.

Server Side Configuration

Now that we have the sub store set up in the Magento admin area we are going to need to configure the server side settings so people can actually access it.

Firstly we will are going to need to connect to our server using SSH and go to the directory of our sub shop using the following line of code (remember to replace substore with the account username of sub store):


cd /home/substore/public_html

From there we are going to need to copy a few files over from our original Magento install starting with the index.php and .htaccess:


cp /home/mainstore/public_html/index.php /home/mainstore/public_html/.htaccess .

We are then going to need to open up the index.php file and change the following line:

$mageFilename = 'app/Mage.php';

To:

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

With the index.php still open replace the following line:


Mage::run();

with the following (replace macsrus with the code you chose in the Create Website section):


Mage::run('macsrus', 'website');

Now we just need to create symbolic links back to a few directories from our original install:


ln -s /home/mainstore/public_html/404/ ./404
ln -s /home/mainstore/public_html/app/ ./app
ln -s /home/mainstore/public_html/includes/ ./includes
ln -s /home/mainstore/public_html/js/ ./js
ln -s /home/mainstore/public_html/media/ ./media
ln -s /home/mainstore/public_html/report/ ./report
ln -s /home/mainstore/public_html/skin/ ./skin
ln -s /home/mainstore/public_html/var/ ./var

One last step to get all of this all working we will need to disable suEXEC, if you’re using WHM you can do this by going to the Configure Suexec and PHP section under the Service Configuration heading and switching Apache suEXEC to off.

Leave a Reply