Search code examples
phpmagentoenvironment

Magento PHP-FPM cannot set Mage_Run_Code


I recently came across a issue when I am trying to set up multi site for a client. Everything works fine from my local, but after I deploy to the server and found out the MAGE_RUN_CODE is not displayed from the $_SERVER, instead it is displaying REDIRECT_MAGE_RUN_CODE

the store code for the second store is : comm

enter image description here

enter image description here

The server configuration is PHP-FPM + Mysql, it looks to me that Mage_Run_Code is not set. Because everything is working fine on my local, therefore, I think it is a server configuration issue.


Christophe has posted a perfect work around this, and it works perfectly.

I think I found the cause of this issue. it is the "suExec" in the Apache which securing the PHP that cause this issue.


Solution

  • To run magento under PHP-FPM environment, we replace (in index.php)

    /* Store or website code */
    $mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
    
    /* Run store or run website */
    $mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
    

    By

    /* Store or website code */
    $mageRunCode = isset($_SERVER['REDIRECT_MAGE_RUN_CODE']) ?
    $_SERVER['REDIRECT_MAGE_RUN_CODE'] :
    (isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '');
    //$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
    
    /* Run store or run website */
    $mageRunType = isset($_SERVER['REDIRECT_MAGE_RUN_TYPE']) ?
    $_SERVER['REDIRECT_MAGE_RUN_TYPE'] :
    (isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store');/* Store or website code */