• 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源码至phpdev\vc##\x##\php-7.3.7-src
  • 解压复制扩展源码至phpdev\vc##\x##\php-7.3.7-src\ext或phpdev\vc##\x##\pecl
  • beast扩展需要复制win95nt.hphp-7.3.7-src\main目录。(此文件建议下载一个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

引用资源

php beast windows编译教程-LMLPHP
 
 

jenawant commented on 4 Dec 2019

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

php beast windows编译教程-LMLPHP
 
 

Refactoring commented on 4 Dec 2019

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

php beast windows编译教程-LMLPHP
 
 

jenawant commented on 5 Dec 2019 •

edited 

@Refactoring

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

04-26 01:24
查看更多