magento------实现多域名,多网店步骤

2024-03-25 14:38

本文主要是介绍magento------实现多域名,多网店步骤,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

 

http://www.crucialwebhost.com/blog/how-to-setup-multiple-magento-stores/#addon-domain-method

地址来源

 

 

How To Setup Multiple Magento Stores

by Kyle on December 28, 2008 · Posted in Howto, Magento · 78 Comments

There are numerous ways to setup multiple Magento stores that all share the same codebase and backend, but what method you use depends on your needs.

This article is written with cPanel in mind, though the methodologies listed below apply no matter what control panel you're using.

Jump To Section
  1. URL Structure
  2. Shared Hosting Caveat
  3. Adding Another Store In Magento
  4. Parked Domain Method
  5. Addon Domain Method
  6. Subdomain Method
  7. Subdirectory Method
  8. Managing Multiple Stores
  9. Secure Checkout For Each Domain

URL Structure

The actual URL structure of your stores is a matter of personal preference. You can, for example, have two entirely different stores running on the same domain that share the same instance of Magento:

  • mall.com/shoes
  • mall.com/shirts

These stores could also be setup on their own domain and still share the same instance of Magento:

  • shoes.com
  • shirts.com

Another example would be a mall type setup, where your primary domain is the portal to access various stores:

  • mall.com
  • shoes.mall.com
  • shirts.mall.com

Regardless of the URL structure, the method for setting this up will pretty much be the same, and the result is what we're really after, which is to have one codebase for all of your stores, and one backend to manage all of these stores from.

Shared Hosting Caveat

If you want each store to have it's own SSL certificate and don't want to share a single checkout, e.g. you don't want visitors leaving domainA.com to checkout on domainB.com, then you will not be able to do this in a shared hosting environment.

The reason why you cannot do this is simple. In order for a website to have an SSL certificate, it requires a dedicated IP address.

There's no way to allow an addon or parked domain in cPanel to have its own IP address. Instead, it shares the IP address of the primary domain.

You probably think you could sign up for two shared hosting accounts, so each one has its own dedicated IP address, but that won't work either.

Since it's shared hosting, there are security measures in place to prevent one user from reading the files of another user.

So for shared hosting clients, you're limited to the following scenarios:

  1. All of your stores do not have a secure checkout, which is fine if you're using PayPal, Google Checkout, or a similar third-party service that handles the processing of card data on their website. For example, visitors to any of your stores are redirected to a third-party website for card processing.
  2. All of your stores share a secure checkout point. For example, you own three domains: mall.com, shoes.com, and shirts.com You use mall.com as your primary domain and have an SSL certificate associated with it. The other two domains would be either addon or parked domains, and visitors to those sites would be redirected to mall.com to checkout.
  3. All of your stores are setup as subdomains, and you've purchased a wildcard SSL certificate, which is roughly $1000/year and is for legally registered businesses.

If you do need an SSL certificate for all of your domains, you will need to be in a dedicated hosting environment, such as our Split-Dedicated platform. In this type of environment, all domains will be able to access the same set of files.

Adding Another Store In Magento

The first thing we need to do is setup our second store in Magento.

If you don't know how to install Magento, read our tutorial or submit a ticket to the Magento department.

We're going to do a hypothetical here for the naming conventions, and assume we ownshirts.com. Adjust the values accordingly for your own store.

  1. Login to the Magento admin.
  2. Go to the Catalog tab, and select Manage Categories.
  3. Click on the Add Root Category button on the left.
  4. On the right, for the Name, we'll enter Shoes.com. Set the dropdown to Yes for both Is Active and Is Anchor.
  5. Click the Save Category button.
  6. Go to the System tab and select Manage Stores.
  7. Click on the Create Website button.
  8. For the Name, we'll enter Shoes.com, and for the Code, we'll enter shoes. We'll use this value later, so don't forget this!
  9. Click the Save Website button.
  10. Click on the Create Store button.
  11. For the Website, select Shoes.com from the dropdown. For the Name, we'll enter Main Store. For the Root Category, select the Shoes.com from the dropdown.
  12. Click on the Save Store button.
  13. Click on the Create Store View button.
  14. For the Store, select Main Store from the dropdown, making sure it's for theShoes.com website. For the Name, we'll enter English. For the Code, we'll entershoes_en. For the Status, select Enabled from the dropdown.
  15. Click the Save Store View button.
  16. Go to the System tab and select Configuration.
  17. For the Current Configuration Scope (located on the top left), change the dropdown menu from Default Config to Shoes.com.
  18. Select Web from the sidebar on the left under the General heading.
  19. For both the Unsecure and Secure sections, uncheck the Use default box next to theBase URL item, and enter the URL for your store, e.g. http://www.shoes.com/. Don't forget the trailing slash!
  20. Click the Save Config button.

Now that we have our second store setup, you'll need to choose one of the following methods for actually setting up the store on the server-side so visitors can access it.

If the URL structure you've chosen will have different domains for each store, the parked domain method is the fastest and easiest method.

Parked Domain Method

For this method, we'll pretend we own shirts.com and shoes.com. The shirts.com domain is our primary domain, and Magento is already installed on it. Here's how we would set this up for the shoes.com domain:

  1. Login to cPanel for your domain and click on the Parked Domains icon.
  2. In the input field, enter the domain name that you'll be setting up as a second store, e.g.shoes.com.
  3. Click on the Add Domain button.
  4. Open up the index.php file for Magento and replace the last line of code:
    Mage::run();

    …with the following code:

    switch($_SERVER['HTTP_HOST']) {
    case 'shoes.com':
    case 'www.shoes.com':
    Mage::run('shoes', 'website');
    break;
    default:
    Mage::run();
    break;
    }

    If you have more than two stores, you will need to add additional cases to the above code block, e.g.:

    switch($_SERVER['HTTP_HOST']) {
    // Shoes.com
    case 'shoes.com':
    case 'www.shoes.com':
    Mage::run('shoes', 'website');
    break;
    // Hats.com
    case 'hats.com':
    case 'www.hats.com':
    Mage::run('hats', 'website');
    break;
    // Shirts.com (default store)
    default:
    Mage::run();
    break;
    }

Addon Domain Method

This is the same scenario as above, except it takes a little longer to setup. This method might be more useful to you if, for example, you wanted to have a blog on one domain, but not on the other. You couldn't do that with a parked domain. Here's how we would set this up for theshoes.com domain:

  1. Login to cPanel for your domain, and click on the Addon Domains icon.
  2. For the New Domain Name, we'll enter shoes.com. cPanel will automatically fill in the next two fields, so remove public_html/ from the Document Root field, leaving us with just shoes.com. This step isn't required, but for organizational purposes, it makes more sense.
  3. Set a password for this domain and click on the Add Domain button.
  4. Login to your site via SSH, and go to the directory that we previously set in theDocument Root field above when adding our domain. In our case, we would do the following:
    cd shoes.com/
  5. Copy the index.php and .htaccess file from the directory where Magento is installed, which would be in our root web directory:
    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:
    $mageFilename = 'app/Mage.php';

    …with the following:

    $mageFilename = '../public_html/app/Mage.php';
  7. With the index.php file still open, replace the following line of code:
    Mage::run();

    …with the following:

    Mage::run('shoes', 'website');
  8. Lastly, we need to create symbolic links to point to a few directories:
    ln -s ../public_html/404/ ./404
    ln -s ../public_html/app/ ./app
    ln -s ../public_html/includes/ ./includes
    ln -s ../public_html/js/ ./js
    ln -s ../public_html/media/ ./media
    ln -s ../public_html/report/ ./report
    ln -s ../public_html/skin/ ./skin
    ln -s ../public_html/var/ ./var

Subdomain Method

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.:

  • 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.
  2. 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.
  3. Click the Create button.
  4. Login to your site via SSH, and go to the directory that we previously set in theDocument Root field above when creating our subdomain. In our case, we would do the following:
    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:
    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:
    $mageFilename = 'app/Mage.php';

    …with the following:

    $mageFilename = '../public_html/app/Mage.php';
  7. With the index.php file still open, replace the following line of code:
    Mage::run();

    …with the following:

    Mage::run('shoes', 'website');
  8. Lastly, we need to create symbolic links to point to a few directories:
    ln -s ../public_html/404/ ./404
    ln -s ../public_html/app/ ./app
    ln -s ../public_html/includes/ ./includes
    ln -s ../public_html/js/ ./js
    ln -s ../public_html/media/ ./media
    ln -s ../public_html/report/ ./report
    ln -s ../public_html/skin/ ./skin
    ln -s ../public_html/var/ ./var

Subdirectory Method

This is the same scenario as above, except all of the shops will be in subdirectories, e.g.:

  • mall.com/shoes
  • mall.com/shirts

Here's how we would set this up for the shoes subdirectory:

  1. Login to your site via SSH, and create a subdirectory where your second store will be:
    cd public_html
    mkdir shoes/
    cd shoes/
  2. Copy the index.php and .htaccess file from the directory where Magento is installed, which would be in our root web directory:
    cp ../public_html/index.php ../public_html/.htaccess .
  3. Open up the index.php file that we just copied over and replace the following line of code:
    $mageFilename = 'app/Mage.php';

    …with the following:

    $mageFilename = '../public_html/app/Mage.php';
  4. With the index.php file still open, replace the following line of code:
    Mage::run();

    …with the following:

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

Managing Multiple Stores

It's very important to remember that now that you have multiple stores to manage from one admin panel, that you make sure you're changing the configuration for the appropriate store.

In the System → Configuration section, if you leave the dropdown menu for Current Configuration Scope set to Default Config, it will globally change the values for all of your stores, assuming you haven't removed the checkmark next to Use default throughout the configuration sections.

You can change the configuration values globally, for each website, and for individual store views.

Secure Checkout For Each Store

For those of you in dedicated hosting environments, you can follow either the addon or parked domain method from above, and edit the httpd.conf file to give the addon or parked domain a dedicated IP address.

However, this is not advised. Your changes will most likely be overwritten with a control panel upgrade, Apache or PHP rebuild, or even simple maintenance.

Your best bet would be to setup each store as a separate account, which can be done in WHM if you have access to it, or in the case of our Split-Dedicated product, something we will be able to set up for you.

Once you have all of your domains setup as individual accounts, you would follow steps 5-8 for the addon domain method, except you're going to use absolute paths instead of relative paths, e.g.:

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

…and for symbolic links:

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

Lastly, in order for the above to work, you will need suEXEC disabled. This won't be a problem in a dedicated hosting environment, since you don't have to worry about other people being able to access your files.

This is just one of the many advantages of running your online business in a more secure and flexible hosting environment like this. If you're on our Split-Dedicated product, this is something we'll have to disable for you.

Once you've done the above, all of your stores will have their own secure checkout and IP address, but will still share the same codebase and backend for management purposes.

Updates

Multi-Store Setup For 1.4.x

Please refer to the following blog post for changes on setting this up on the 1.4.x version of Magento:

http://cwhurl.com/mmss

Wildcard SSL Certificate

If you're having trouble installing a wildcard SSL certificate with cPanel and setting it up on all your subdomains, please refer to knowledge base article for help.

这篇关于magento------实现多域名,多网店步骤的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/845315

相关文章

python使用watchdog实现文件资源监控

《python使用watchdog实现文件资源监控》watchdog支持跨平台文件资源监控,可以检测指定文件夹下文件及文件夹变动,下面我们来看看Python如何使用watchdog实现文件资源监控吧... python文件监控库watchdogs简介随着Python在各种应用领域中的广泛使用,其生态环境也

el-select下拉选择缓存的实现

《el-select下拉选择缓存的实现》本文主要介绍了在使用el-select实现下拉选择缓存时遇到的问题及解决方案,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的... 目录项目场景:问题描述解决方案:项目场景:从左侧列表中选取字段填入右侧下拉多选框,用户可以对右侧

springboot整合 xxl-job及使用步骤

《springboot整合xxl-job及使用步骤》XXL-JOB是一个分布式任务调度平台,用于解决分布式系统中的任务调度和管理问题,文章详细介绍了XXL-JOB的架构,包括调度中心、执行器和Web... 目录一、xxl-job是什么二、使用步骤1. 下载并运行管理端代码2. 访问管理页面,确认是否启动成功

Python pyinstaller实现图形化打包工具

《Pythonpyinstaller实现图形化打包工具》:本文主要介绍一个使用PythonPYQT5制作的关于pyinstaller打包工具,代替传统的cmd黑窗口模式打包页面,实现更快捷方便的... 目录1.简介2.运行效果3.相关源码1.简介一个使用python PYQT5制作的关于pyinstall

使用Python实现大文件切片上传及断点续传的方法

《使用Python实现大文件切片上传及断点续传的方法》本文介绍了使用Python实现大文件切片上传及断点续传的方法,包括功能模块划分(获取上传文件接口状态、临时文件夹状态信息、切片上传、切片合并)、整... 目录概要整体架构流程技术细节获取上传文件状态接口获取临时文件夹状态信息接口切片上传功能文件合并功能小

python实现自动登录12306自动抢票功能

《python实现自动登录12306自动抢票功能》随着互联网技术的发展,越来越多的人选择通过网络平台购票,特别是在中国,12306作为官方火车票预订平台,承担了巨大的访问量,对于热门线路或者节假日出行... 目录一、遇到的问题?二、改进三、进阶–展望总结一、遇到的问题?1.url-正确的表头:就是首先ur

C#实现文件读写到SQLite数据库

《C#实现文件读写到SQLite数据库》这篇文章主要为大家详细介绍了使用C#将文件读写到SQLite数据库的几种方法,文中的示例代码讲解详细,感兴趣的小伙伴可以参考一下... 目录1. 使用 BLOB 存储文件2. 存储文件路径3. 分块存储文件《文件读写到SQLite数据库China编程的方法》博客中,介绍了文

Redis主从复制实现原理分析

《Redis主从复制实现原理分析》Redis主从复制通过Sync和CommandPropagate阶段实现数据同步,2.8版本后引入Psync指令,根据复制偏移量进行全量或部分同步,优化了数据传输效率... 目录Redis主DodMIK从复制实现原理实现原理Psync: 2.8版本后总结Redis主从复制实

JAVA利用顺序表实现“杨辉三角”的思路及代码示例

《JAVA利用顺序表实现“杨辉三角”的思路及代码示例》杨辉三角形是中国古代数学的杰出研究成果之一,是我国北宋数学家贾宪于1050年首先发现并使用的,:本文主要介绍JAVA利用顺序表实现杨辉三角的思... 目录一:“杨辉三角”题目链接二:题解代码:三:题解思路:总结一:“杨辉三角”题目链接题目链接:点击这里

基于Python实现PDF动画翻页效果的阅读器

《基于Python实现PDF动画翻页效果的阅读器》在这篇博客中,我们将深入分析一个基于wxPython实现的PDF阅读器程序,该程序支持加载PDF文件并显示页面内容,同时支持页面切换动画效果,文中有详... 目录全部代码代码结构初始化 UI 界面加载 PDF 文件显示 PDF 页面页面切换动画运行效果总结主