Page 1 of 1

How To Setup Multiple Magento Stores (Subdomain Method)

Posted: Mon Oct 03, 2011 5:03 pm
by Nipuna
For this method, we'll pretend we own mall.com, and it's setup as a portal that links to the various shops within the mall. Magento will be installed on the mall.com domain, and all of the shops will be in subdomains, e.g.:

Code: Select all

    
shoes.mall.com
Shirts.mall.com
Here's how we would set this up for the shoes subdomain:

1 Login to cPanel for your domain, and click on the Subdomains icon.
For the Subdomain, we'll enter shoes. cPanel will automatically fill in the next field, so remove public_html/ from the Document Root field, leaving us with just shoes. This step isn't required, but for organizational purposes, it makes more sense.
2 Click the Create button.
3 Login to your site via SSH, and go to the directory that we previously set in the Document Root field above when creating our subdomain. In our case, we would do the following:

Code: Select all

cd shoes/
5 Copy the index.php and .htaccess file from the directory where Magento is installed, which would be in our root web directory:

Code: Select all

cp ../public_html/index.php ../public_html/.htaccess .

6
Open up the index.php file that we just copied over and replace the following line of code:

Code: Select all

$mageFilename = 'app/Mage.php';
…with the following:

Code: Select all

$mageFilename = '../public_html/app/Mage.php';
7 With the index.php file still open, look for this line (it's the last line of the file):

Code: Select all

Mage::run($mageRunCode, $mageRunType);
…and right before this, we're going to add the following code:

Code: Select all

$mageRunCode = 'shoes';
$mageRunType = 'website';
8 Lastly, we need to create symbolic links to point to a few directories:

Code: Select all

ln -s ../public_html/app ./app
ln -s ../public_html/errors ./errors
ln -s ../public_html/includes ./includes
ln -s ../public_html/js ./js
ln -s ../public_html/lib ./lib
ln -s ../public_html/media ./media
ln -s ../public_html/skin ./skin
ln -s ../public_html/var ./var

Here is the link to My past post about adding Domains to Magento stores, Which has the other methods

https://robot.lk/viewtopic.php?f=74&t=2813

Re: How To Setup Multiple Magento Stores (Subdomain Method)

Posted: Tue Oct 04, 2011 10:45 am
by Saman
Nice one.

Re: How To Setup Multiple Magento Stores (Subdomain Method)

Posted: Tue Oct 04, 2011 10:46 am
by Nipuna
Thanks

Re: How To Setup Multiple Magento Stores (Subdomain Method)

Posted: Tue Oct 04, 2011 10:51 am
by Neo
Nice one indeed. I'm sure this will be very helpful for someone who's working with Magento.

Re: How To Setup Multiple Magento Stores (Subdomain Method)

Posted: Tue Oct 04, 2011 10:52 am
by Nipuna
Thanks :)