Search code examples
phpwinginx

How to use PHP 5.6 in Winginx


I would like to use php 5.6 with Winginx.

I tried to create a folder php56 and put the php package into it, but the php-config.exe will not "see" this folder.

How can I configure this php version in Winginx?


Solution

  • <?php
    /*
    After applying this patch you can use "php56", "php70" and "php71"
    folders in the root directory of winginx.
    */
    function patch($file, $offset, $old_data, $new_data) {
        if (!$f = fopen($file, 'r+b')) {
            die("Can not open $file");
        }
        fseek($f, $offset);
        $c = fread($f, strlen($old_data));
        if ($c == $old_data) {
            fseek($f, $offset);
            fwrite($f, $new_data, strlen($new_data));
            echo "$file patched successfully\n";
        } else if ($c != $new_data) {
            die("$file can not be patched\n");
        }
        fclose($f);
    }
    patch('winginx.exe', 0x0A6254, 2, 6); // 5.2 -> 5.6
    patch('winginx.exe', 0x0A6258, 5, 7);  
    patch('winginx.exe', 0x0A625C, 3, 0); // 5.3 -> 7.0
    patch('winginx.exe', 0x0A6260, 5, 7);
    patch('winginx.exe', 0x0A6264, 4, 1); // 5.4 -> 7.1
    
    patch('winginx.exe', 0x0AD2DC, 2, 6); // 5.2 -> 5.6
    patch('winginx.exe', 0x0AD2EA, 5, 7);
    patch('winginx.exe', 0x0AD2EC, 3, 0); // 5.3 -> 7.0
    patch('winginx.exe', 0x0AD2FA, 5, 7);
    patch('winginx.exe', 0x0AD2FC, 4, 1); // 5.4 -> 7.1
    
    patch('php-config.exe', 0x014FCE, 2, 6); // 5.2 -> 5.6
    patch('php-config.exe', 0x014FDC, 5, 7);
    patch('php-config.exe', 0x014FDE, 3, 0); // 5.3 -> 7.0
    patch('php-config.exe', 0x014FEC, 5, 7);
    patch('php-config.exe', 0x014FEE, 4, 1); // 5.4 -> 7.1
    
    echo "Done\n";
    

    to update mysql to latest 5.7 release:

    • download latest zip versin
    • extract mysqld.exe and share folder to the mysqll folder of winginx
    • use this my.ini

      [mysqld]
      basedir=../mysql
      datadir = data
      bind-address = 127.0.0.1
      socket=mysql.sock
      log_syslog=0
      log_error_verbosity=1 # 1=errors; 2=+warnings; 3=+notices
      
    • rename data folder to something else (to backup data)
    • run from mysql filder of winginx

      ./mysqld.exe --initialize-insecure --console --datadir=data --basedir=../mysql
      

    nginx, nodejs and redis could be updated the same way. download latest release, replace binaries and play with configs