步骤1:在Magento后台创建websites, stores, 和 store views

  1. 登录到Magento后台创建websites, stores, 和 store views。
  2. 单击Stores>Settings>All Stores
  3. 在Stores页面上,点击Create Website
    • Name字段:输入名称以标识网站。
    • Code字段:输入唯一的代码;例如,如果您有法国商店或德国商店,则可以输入french, german
    • Sort Order字段:输入数字用来识别排序顺序。
  4. 单击Save Web Site

步骤2:创建Apache虚拟主机

  1. 以具有root 用户特权的用户身份,在文本编辑器中打开虚拟主机配置文件。
  2. 例如,打开/etc/httpd/conf/httpd.conf
  3. 找到以<VirtualHost *:80> 开头的部分。
  4. 在任何现有虚拟主机之后创建以下虚拟主机:
  5. 
       ServerName          mylocalsite.com
       DocumentRoot        /var/www/html/magento2/pub/
    
    
    
       ServerName          french.mylocalsite.com
       DocumentRoot        /var/www/html/magento2/pub/
       SetEnv MAGE_RUN_CODE "french"
       SetEnv MAGE_RUN_TYPE "website"
    
    
    
       ServerName          german.mylocalsite.com
       DocumentRoot        /var/www/html/magento2/pub/
       SetEnv MAGE_RUN_CODE "german"
       SetEnv MAGE_RUN_TYPE "website"
    
    
  6. 将更改保存到httpd.conf 并退出文本编辑器。
  7. 重新启动Apache:
    • CentOS:service httpd restart
    • Ubuntu:service apache2 restart

步骤3:验证您的网站

  1. 打开操作系统的hosts文件。
  2. 以以下格式添加静态路由:
  3. <ip地址> french.mylocalsite.com <ip地址> german.mylocalsite.com
  4. 在浏览器中打开以下URL之一:
  5. http://mylocalsite.com/admin http://french.mylocalsite.com/frenchstoreview http://german.mylocalsite.com/germanstoreview