【问题标题】:How to use PHP 5.6 in Winginx如何在 Winginx 中使用 PHP 5.6
【发布时间】:2014-10-02 08:41:32
【问题描述】:

我想在 Winginx 上使用 php 5.6。

我试图创建一个文件夹php56并将php包放入其中,但是php-config.exe不会“看到”这个文件夹。

如何在 Winginx 中配置这个 php 版本?

【问题讨论】:

    标签: php winginx


    【解决方案1】:
    <?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";
    

    将 mysql 更新到最新的 5.7 版本:

    • 下载最新的 zip 版本
    • 解压mysqld.exe并共享文件夹到winginx的mysqll文件夹中
    • 使用这个 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
      
    • 将数据文件夹重命名为其他名称(用于备份数据)
    • 从 winginx 的 mysql 文件夹运行

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

    nginx、nodejs 和 redis 可以用同样的方式更新。下载最新版本,替换二进制文件并使用配置

    【讨论】:

      【解决方案2】:
      <?php
      /*
      After applying this patch you can use "php56" and "php70"
      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);
      patch('winginx.exe', 0x0AD2DC, 2, 6);
      
      patch('winginx.exe', 0x0AD258 5, 7);
      patch('winginx.exe', 0x0AD25C 3, 0);
      patch('winginx.exe', 0x0AD2EA 5, 7);
      patch('winginx.exe', 0x0AD2EC 3, 0);
      
      patch('php-config.exe', 0x014FCE, 2, 6);
      patch('php-config.exe', 0x014FDC, 5, 7);
      patch('php-config.exe', 0x014FDE, 3, 0);
      
      echo "Done\n";
      

      【讨论】:

      • 您能否在答案中添加更多细节?谢谢!
      • 哪些较旧的 PHP 版本会被此补丁覆盖?
      • 我会接受这是一个足够的答案,因为显然 Winginx 项目已经一年多没有维护了。我不希望官方开发人员有任何更新。谢谢你的补丁。
      【解决方案3】:

      你可以这样做,

      PHP 设置; 首先,下载到 php (http://windows.php.net/download/) 并复制到 C:/php。 之后,在桌面上创建php64.bat,写入C:\php\php-cgi.exe -b 127.0.0.1:5800里面,运行文件。

      Winginx 设置; 更改为您的“服务器配置”选项卡; 查找:

      location ~ \.php$ {
          fastcgi_pass 127.0.0.1:9054;
      

      替换:

      location ~ \.php$ {
          fastcgi_pass 127.0.0.1:5800;
      

      之后,保存并重启 nginx。

      【讨论】:

      • 感谢您的帮助。我的问题是 PHP 5.6 如何与 WinGinx 一起使用。设置 php 的“独立”实例使 Winginx 的使用毫无意义。我喜欢 WinGinx 中简单的配置选项,并且更愿意使用它们。
      【解决方案4】:

      试试……

      对于 php 5.6.7 - https://github.com/z2z/winginx_php56

      对于 mysql 或 mariadb - https://gist.github.com/z2z/eb3d1415c2521da76b20

      对于 nGinx - 您直接将 nginx.exe 替换为最新的。

      【讨论】:

      • 您是否修补了 PHP 以报告不同的版本号?
      • 是的。您必须对其进行修补,因为版本在 winginx 中是硬编码的。您可以使用这些文件夹中的任何一个..`“/php5/”、“/php52/”、“/php53/”、“/php54/”、“/php55/”、“/php4/”、“/php3/ ", "/php/"`
      【解决方案5】:

      你在这里:https://www.dropbox.com/s/10mkdporeils7ct/winginx_php56_support.exe 我刚刚重新编辑,现在它支持 php 5.6。

      只需从 php.net 5.6 下载 php 并放置到 winginx_folder/php56 你还需要从以前的版本复制配置 php-cgi。

      【讨论】:

      • 因为您建议从私人 Dropbox 帐户下载随机二进制文件并不能激发太多信心。此外,它没有解释你做了什么,或者你是如何做到的。请编辑您的帖子以解释您所做的事情,以便将来其他人可以使用相关软件的更新版本复制它。
      猜你喜欢
      • 2020-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-17
      • 2016-03-26
      • 1970-01-01
      相关资源
      最近更新 更多