One of Magento’s greatest features is the ability to add multiple websites and store views which can share the same code base and admin area, making management a lot easier. This article will run through setting up Magento multiple sites via cPanel.
Magento gives the user the ability to perform the initial steps to setup a multisite application with a section in the admin under
System -> Manage Stores.
You should have at least one store view added against a store, and at least one store added against a website.
Run through adding these components and keep a note of the website code you added against the new website.
Your website will have a different URL to your main website’s, so within the
System -> Configuration -> Web section, change the configuration scope dropdown on the left hand side and edit the Unsecure and Secure Base URLs to match the URL of your addon website.
Usually, the second domain will use a separate theme in order to load different design changes, so change this (and the package name if a new one is being used) within the
System -> Configuration -> Design section.
Now that the Magento setup is finished, within cPanel, click on the
Addon Domains icon underneath the
You’ll then be able to add in your domain name, configure a subdomain if used, and specify the document root.
It is recommended to set the document root of the second website outside of the default document root given to your first site, so if your website’s document root is
home/[accountname]/public_html, set the second site’s document root to be
If you have added the Addon Domain correctly, you should see it appear like below.
cPanel will already create the second site’s document root for you.
As we do not want to duplicate the Magento application files for each website we add, we’ll need to set up symlinks.
To do this, log into your server via SSH. You should have the following folder structure set up.
/home /[accountname] /public_html // Magento code here /site2.com // The symlinks will be set up here.
You can add symbolic links to each Magento directory using the following.
ln -s /home/[accountname]/public_html/app /home/[accountname]/site2.com/app ln -s /home/[accountname]/public_html/errors /home/[accountname]/site2.com/errors ln -s /home/[accountname]/public_html/includes /home/[accountname]/site2.com/includes ln -s /home/[accountname]/public_html/js /home/[accountname]/site2.com/js ln -s /home/[accountname]/public_html/lib /home/[accountname]/site2.com/lib ln -s /home/[accountname]/public_html/media /home/[accountname]/site2.com/media ln -s /home/[accountname]/public_html/skin /home/[accountname]/site2.com/skin ln -s /home/[accountname]/public_html/var /home/[accountname]/site2.com/var
Lastly, take a copy of the
index.php file and paste them into site2.com’s document root alongside the symlinks.
.htaccess, set environment variables for
MAGE_RUN_CODE will be the website’s code from earlier in the article, and
MAGE_RUN_TYPE will be
SetEnv MAGE_RUN_CODE web_2 SetEnv MAGE_RUN_TYPE website
If you’ve set your second domain’s DNS records to correctly point to your server, you should now be able to access your second website using the same Magento code. Congratulations!