ddev WSL2 Magento 2 多存储集 $MAGE_RUN_CODE & $MAGE_RUN_TYPE

ddev WSL2 Magento 2 multistore set $MAGE_RUN_CODE & $MAGE_RUN_TYPE

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

在 ddev 中,您可以在配置中全局或本地设置环境变量,参见 https://ddev.readthedocs.io/en/stable/users/extend/customization-extendibility/#providing-custom-environment-variables-to-a-container

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

web_environment:
- MAGE_RUN_CODE =someval
- MAGE_RUN_TYPE =someotherval

我通过覆盖 .ddev/nginx_full/nginx-site.conf 并将以下行添加到服务器块的顶部(就在它定义 if ($mage_run_code = '') {:

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

现在一切正常。

谢谢