skip to Main Content

Anyone know how can set the $MAGE_RUN_CODE & $MAGE_RUN_TYPE variables for a Magento 2 multi site using ddev-local?
I have added the new domain to the additional_hostnames variable in .ddev/config.yaml – but now I need to tell the nginx docker container to serve the magento store front when that newstorefront.ddev.site domain is requested.
Any ideas? Thanks.

2

Answers


  1. Chosen as BEST ANSWER

    I have got this working by overriding the .ddev/nginx_full/nginx-site.conf and adding the following lines towards the top of the server block (just before where it defines if ($mage_run_code = '') {:

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

    Now it all works correctly.

    Thanks


  2. In ddev you can set environment variables globally or locally in the config, see https://ddev.readthedocs.io/en/stable/users/extend/customization-extendibility/#providing-custom-environment-variables-to-a-container

    Basic idea: add this to your .ddev/config.yaml:

    web_environment:
    - MAGE_RUN_CODE =someval
    - MAGE_RUN_TYPE =someotherval
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search