zoukankan      html  css  js  c++  java
  • php beast windows编译教程

    • git clone https://github.com/Microsoft/php-sdk-binary-tools.git c:php-sdk
    • cd c:php-sdk
    • git checkout php-sdk-2.1.9 or later
    • invoke phpsdk-vc15-x64.bat
    • phpsdk_buildtree phpmaster
    • git clone https://github.com/php/php-src.git && cd php-src, or fetch a zipball
    • phpsdk_deps --update --branch master, use phpsdk_deps --update --branch X.Y for a non master branch
    • do the build, eg. buildconf && configure --enable-cli && nmake

    Windows编译PHP拓展

    1.离线下载并安装Build Tools(对应Visual Studio 2017)

    下载连接:vs_buildtools.exe
    离线下载脚本:

    vs_buildtools.exe --layout E:VS2017BuildTools --add Microsoft.VisualStudio.Workload.VCTools --lang zh-CN
    

    2. 下载,解压PHP-SDK工具包

    https://github.com/Microsoft/php-sdk-binary-tools

    3. PHP-SDK配置,加载

    # 命令行进入解压路径,按自己需求执行对应的批处理脚本
    >phpsdk-vc15-x64.bat
    $> phpsdk_buildtree phpdev
    

    4. 下载PHP-SDK编译依赖组件

    $> phpsdk_deps -u 
    # 或手工下载([依赖下载链接](https://windows.php.net/downloads/php-sdk/deps))并解压至deps目录
    # 下载目录对应当前上级目录文件名
    

    5. 下载,复制PHP源码,下载,复制扩展源码。

    • 可在当前目录下载,解压多个PHP版本的源码。
    • vc## 编译工具版本(eq vc15),x## CPU版本 (x86 or x64)
    • 解压复制PHP源码至phpdevvc##x##php-7.3.7-src
    • 解压复制扩展源码至phpdevvc##x##php-7.3.7-srcext或phpdevvc##x##pecl
    • beast扩展需要复制win95nt.hphp-7.3.7-srcmain目录。(此文件建议下载一个PHP7.1x的源码,在main目录。)

    务必修改beast源码文件config.w32,替换为如下内容。源码有错误,作者后期新加的代码漏了execute-normal-script配置信息:

    // $Id$
    // vim:ft=javascript
    
    // If your extension references something external
    ARG_WITH("beast", "for beast support", "yes,shared");
    
    
    ARG_ENABLE("beast", "enable beast support", "yes,shared");
    
    ARG_ENABLE("beast-debug", "enable beast debug mode", "no");
    
    ARG_ENABLE("execute-normal-script", "Enable execute normal PHP script", "yes");
    
    if (PHP_BEAST != "no") {
    	if (PHP_BEAST_DEBUG != "no") {
    		AC_DEFINE('BEAST_DEBUG_MODE', 1, 'Debug support in beast');
    	}
    	if (PHP_EXECUTE_NORMAL_SCRIPT != "no") {
    		AC_DEFINE('BEAST_EXECUTE_NORMAL_SCRIPT', 1, [ ]);
    	}
    	
    	EXTENSION("beast", "beast.c aes_algo_handler.c des_algo_handler.c base64_algo_handler.c beast_mm.c spinlock.c cache.c beast_log.c global_algo_modules.c header.c networkcards.c tmpfile_file_handler.c file_handler_switch.c shm.c", true);
    }
    

    6. 编译扩展

    $>cd php-7.3.7-src
    $>buildconf
    $>configure --help   #查找编译扩展关键字,确定配置参数
    # 线程安全编译
    $>configure --disable-all --enable-cli --without-beast --enable-execute-normal-script=yes --disable-beast=shared && nmake
    # 非线程安全编译
    $>configure --disable-zts --disable-all --enable-cli --without-beast --enable-execute-normal-script=yes --disable-beast=shared && nmake
    

    重新编译脚本

    # Recompile after you have done some changes
    1. Clean up old compiled binaries
    nmake clean
    2. If you need to update the 'configure' script
    buildconf --force
    3. Create your makefile: see release
    configure --disable-all --enable-cli --enable-$remains
    4. Compile
    nmake
    

    引用资源

    1. 在windows10下php7.3+编译phalcon扩展 https://www.jianshu.com/p/9dca99f7d4a9
    2. Windows编译PHP7.2拓展 https://segmentfault.com/a/1190000016011547
    3. https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2
    @jenawant
     
     

    jenawant commented on 4 Dec 2019

    你直接在vs里面编译就好了

    你好,请教一下,目前PHP用的版本是5.6,应该如何生成dll呢?试了好多网上的方案,都不行,还请指导一下 ,谢谢。

    @Refactoring
     
     

    Refactoring commented on 4 Dec 2019

    @jenawant
    5.6我这也没有成功,放弃5.6了。我编译环境太多,最后再没折腾。
    服务器自己有权折腾,就升级吧,同样的代码7.x性能好的不得了(开启opcache)。

    @jenawant
     
     

    jenawant commented on 5 Dec 2019 • 

    edited 

    @Refactoring

    感谢回复,基于你的方案,然后参考PHP官方文档,在5.6.40下编译成功了,谢谢。
    接受你的建议,接下来,要搞PHP7的版本。

    引用资源:http://ishere.cn/2019/12/05/windows10-compile-php-extension.html

  • 相关阅读:
    用户登录
    open >>>文件操作
    随机数
    内置函数
    函数练习
    函数的动态参数
    函数的指定参数
    函数的普通参数
    函数的初步认识
    copy
  • 原文地址:https://www.cnblogs.com/xiami2046/p/12693435.html
Copyright © 2011-2022 走看看