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.h 至php-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
引用资源 |