Setup multiple storeviews

If a website has multiple store views (domain names with different view), make sure the run codes are configured

magerun2 sys:store:config:base-url:list

+----+-----------+------------------------------+------------------------------+

| id | code      | unsecure_baseurl             | secure_baseurl               |

+----+-----------+------------------------------+------------------------------+

| 1  | english   | https://domain.example/      | https://domain.example/      |

| 3  | domainnl  | https://domain.nl/           | https://domain.nl/           |

| 4  | domainfr  | https://domain.fr/           | https://domain.fr/           |

| 5  | default   | https://default.be/          | https://default.be/          |

| 6  | main      | https://main.eu/             | https://main.eu/             |

| 7  | test      | https://test.be/             | https://test.be/             |

+----+-----------+------------------------------+------------------------------+

Now create ~/nginx/mage.runmaps

map $http_host $MAGE_RUN_CODE {    

hostnames;

    .domain.nl domainnl;

    .domain.fr domainfr;

}

map $http_host $MAGE_RUN_TYPE {

    hostnames;

    .domain.nl store;    <--- This could be store or sometimes website

    .domain.fr store;

    default website;

}

Now modify ~/nginx/50main.conf and remove comments (see Delete this comment)

# PHP entry point for main application

location ~ (index|get|static|report|404|503|health_check|opcache_clear|info)\.php$ {

    try_files $uri =404;

    fastcgi_pass    $fastcgi_backend;     # rather use hp defaults

    fastcgi_buffers 1024 4k;

    fastcgi_param  PHP_FLAG  "session.auto_start=off \n suhosin.session.cryptua=off";

    fastcgi_param  PHP_VALUE "memory_limit=2048M \n max_execution_time=18000";

    fastcgi_read_timeout 600s;     fastcgi_connect_timeout 600s;

    # These are set in mage.runmaps

    Delete this comment -> # fastcgi_param   MAGE_RUN_CODE $MAGE_RUN_CODE if_not_empty;

    Delete this comment -> # fastcgi_param   MAGE_RUN_TYPE $MAGE_RUN_TYPE if_not_empty;

    fastcgi_index  index.php;

    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

    include        fastcgi_params;

    fastcgi_param  SERVER_PORT      $http_x_forwarded_port;

}

IMPORTANT NOTE
In case there is already a mage.runmaps defined on the server in another user, you have to call the variabeles in the second mage.runmaps different as per example:

map $http_host $MAGE_RUN_CODE_2 {
...
}

map $http_host $MAGE_RUN_TYPE_2 {
...
}
 
And change those names accordingly in the 50main.conf:
fastcgi_param   MAGE_RUN_CODE $MAGE_RUN_CODE_2 if_not_empty;
fastcgi_param   MAGE_RUN_TYPE $MAGE_RUN_TYPE_2 if_not_empty;


Was this article helpful?

mood_bad Dislike 1
mood Like 1
visibility Views: 3795