ddev WSL2 Magento 2 多商店集 $MAGE_RUN_CODE 和 $MAGE_RUN_TYPE

问题描述 投票:0回答:3

有人知道如何使用 ddev-local 为 Magento 2 多站点设置 $MAGE_RUN_CODE 和 $MAGE_RUN_TYPE 变量吗? 我已将新域添加到 .ddev/config.yaml 中的 extra_hostnames 变量中 - 但现在我需要告诉 nginx docker 容器在请求 newstorefront.ddev.site 域时为 magento 店面提供服务。 有任何想法吗?谢谢。

magento2 ddev
3个回答
2
投票

我通过覆盖 .ddev/nginx_full/nginx-site.conf 并将以下行添加到服务器块的顶部(就在它定义的位置之前)来实现此功能:

if ($mage_run_code = '') {

现在一切正常。

谢谢


1
投票
https://ddev.readthedocs.io/en/stable/users/extend/customization-extendibility/#providing-custom-environment-variables-to- a-容器

基本思想:将其添加到您的 .ddev/config.yaml 中:

if ($http_host = mysecondsite.ddev.site){ set $mage_run_code 'mysecondsite_en'; set $mage_run_type store; }



0
投票

在您的项目文件夹中

web_environment: - MAGE_RUN_CODE =someval - MAGE_RUN_TYPE =someotherval

添加包含以下内容的

MAGENTO_ROOT_FOLDER/.ddev/nginx_full
magento-stores.conf

接下来,打开项目的 
map $http_host $mage_run_code { default ''; store1.ddev.site storecode1; store2.ddev.site storecode2; store3.ddev.site storecode3; }

并添加其他主机名:

MAGENTO_ROOT_FOLDER/.ddev/config.yaml

来源:
https://github.com/jellesiderius/ddev-magento2-setup?tab=readme-ov-file#setting-up-multistore-configuration

© www.soinside.com 2019 - 2024. All rights reserved.