Different test or debug operations require an installation of several websites configuration on a local server. The most popular example is dev website where all testing operations take place.
My main website is set on the local address http://localhost.com/mage1911 (I use the variant with a path because it is a little bit harder than usage without a path). This is a standard website on Magento 1.9.1.1.
Step 1: Add Magento site
- Choose Manage Stores at System->Configuration in the admin area.
- Add a website with the name “Website Alt” with the code website_alt.
- Add a shop with the name “Website Store Alt” and assign the code store_alt to it. the shop should be specified for the site Website Alt. Don’t forget to set a default category.
- Add a few store views to the new shop. Specify Website Store Alt” for the both shops and assign to them names/codes “Alt Eng”/alt_view_eng and “Alt Rus”/alt_view_rus.
Step 2: Alternative Magento site configuration
The alternative website will be open by the address http://localhost.com/mage1911/alt.
Create folder with the name alt(w:/httdocs/mage1911/alt) in the root directory of the main website (for example, in w:/htdocs/mage1911).
Copy 2 files from the root directory in this folder: .htaccess and index.php. Then you have to set a base address for a rewrite. Make a correction in the file alt/.htaccess:
RewriteBase /mage1911/alt/
Note! If this correction isn’t made, you have to switch off alternative store option Use Web Server Rewrites (the addresses will contain index.php)
There should be set correct constant MAGENTO_ROOT address in the file alt/index.php. For example:
define(‘MAGENTO_ROOT’, dirname(getcwd()));
Also, indicate that this file will upload the alternative website:
Mage::run(‘website_alt’, ‘website’);
(you can modify the content of this 2 files according to requirements)
Some programmers recommend making following corrections for the earlier Magento versions:
$compilerConfig = ‘../includes/config.php’; $mageFilename = ‘../app/Mage.php’;
It depends on the requirements. In the latest Magento versions these rows forms from the constant MAGENTO_ROOT (the one that we set properly earlier).
Step 3: Paths configuration
Open System->Configuration and set the settings visibility area (selector Current Configuration Scope) in “Website Alt”.
Open [GENERAL] Web after this and set absolute paths for all URLs fields (by removing markers in Use Default):
Base URL = http://localhost.com/mage1911/alt/ Base Link URL = http://localhost.com/mage1911/alt/ Base Skin URL = http://localhost.com/mage1911/skin/ Base Media URL = http://localhost.com/mage1911/media/
Note! The piece /alt/ is absent in the resource paths, everything comes from the parent store. Of course, if alt folder will be used for skin or/and other resources, the URLs must contain /alt/.
So, it is almost done. Don’t forget to purge cache and do reindex.
Oops.
You open the alternative store and see that it is empty. It’s ok because every product is connected with the website and this connection must be specified.
Open Products Catalog the admin area, click Select All (add a filter before if needed). Choose Update Attributes in the section Action and press Submit. The form with a few tabs will appear, the attributes for the products can be set in a bulk there.
Open section Websites and mark the new website. Save it and see your store full of products.
Oops #2.
Sometimes the original server may have an alternative store that uses symlinks and/or non-recursive directory (from the other path) for the resources (skin, media, etc.). The local server should have the same (or similar) configuration.
The settings won’t changed significantly.
First of all, set all symlinks for the folders app, media, skin, etc.
It can be done in several ways in Windows (there was the time when it was impossible to do it in Windows!). The typical way is to use the command line. Example (run command line in the directory W:\htdocs\mage1911\alt):
mklink /D app W:\htdocs\mage1911\app
It is the symlink for the app folder of the main website (correct slashes are important).
Then you have to do almost the same actions but with some corrections:
- no need to set the constant MAGENTO_ROOT because it specifies correct paths in the recursive directory via symlinks.
- no need to indicate the main website in the resources URLs (skin, media, etc.) because they are available via symlinks (But! The base URL must be set).
This is the end.
I used the information from http://inchoo.net/magento/how-to-set-multiple-websites-with-multiple-store-views-in-magento/