Home >Backend Development >PHP Tutorial >Compile php7.2 under windows and extend judy

Compile php7.2 under windows and extend judy

不言
不言Original
2018-04-08 09:21:142700browse

The content shared in this article is to compile php7.2 under windows and extend Judy. Now I share it with everyone. Friends in need can refer to the content of this article.

I plan to upgrade php to 7.2. I use php7.2, but there is no official compiled version of Judy, an extension I often use...so I plan to compile it myself..

Reference article: http://blog.51cto .com/lancelot/2054953 Compiling php7.2 under windows to extend memcache

1. Compilation environment setup

(1) There are several important differences in the compilation of php7.2 (windows environment).

1.php7.2 is compiled using vc15 (vs2017)

2.php7.2’s php-sdk dsp is no longer available for download on the previous page (the address has been changed)

3. Building the compilation environment is easier.


(2) Building the specific environment

1. Install the vc15 compiler


vs2017 separates the compiler and ide. Because we only need the compiler, we don’t need to install vs2017 (you can also install the free version of vs2017 directly)

http://landinghub .visualstudio.com/visual-cpp-build-tools

Click the download address to go to the download page and find "Visual Studio 2017 Build Tool" below to download Just install it (when installing, please note that you only need to check the box that only requires vc compilation related tools)

2. Download php-sdk and unzip

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

Extract to d:\php_sdk\ (assuming we plan to use d:\php_sdk\ as the compilation directory)

At this time d:\ php_sdk\ There should be


3. Run phpsdk-vc15-x86.bat

in d:\php_sdk\ and press and hold in the php_sdk directory Right-click with shift key and "Open command line window here"

Run "phpsdk-vc15-x86.bat" in the command line window

Note: If you want to compile the 64-bit version, run x64 ,

The result is as shown below (the phpsdk directory is different)


##4. Run php

sdk_buildtree php dev

At this time there should be a phpdev directory under d:\php_sdk\

5. Download the php source code and extract it to d:\php_sdk\phpdev\vc15\x86\php-src

Create the php-src directory under d:\php_sdk\phpdev\vc15\x86\ (64-bit is x64)

Download the php source code and extract it to the php-src directory

At this time d:\php_sdk\phpdev\vc15\x86\php-src\ directory should be as follows (directory The files may be different but this is the root directory of the source code)


# 6. Enter php- src directory, execute the

command line "cd

d:\php_sdk\phpdev\vc15\x86\php-src\" to enter the php-src directory

Command line "php

sdk_deps --update --branch master" PHP will automatically download the required dependency packages (previously, you needed to download the php-dsp file manually)

Wait for the download to complete (Approximately as shown below)

Processing package zlib-1.2.11-vc15-x64.zip
Processing package libsodium-1.0.15-vc15-x64.zip
Updates performed successfully.
Old dependencies backed up into 'D:\php_sdk\phpdev\vc15\x86\deps.201712260650'.

D:\php_sdk\phpdev\vc15\x86\php-src
$

7. Execute "

buildconf"

Command line execution"

buildconf"

If you are prompted that there is no script engine with the file extension ".js"

Baidu "There is no script engine with the file extension ".js""

Follow this https://blog. csdn.net/ctthuangcheng/article/details/16951361


Re-execute

buildconf

The results are as follows

$ buildconf
Rebuilding configure.js
Now run 'configure --help'

D:\php_sdk\phpdev\vc15\x86\php-src
$

8. Compile php

configure --disable-all --enable-cli --enable-zlib --enable-hash --enable-session --without-gd --with-bz2  --enable-fd-setsize=2048 --enable-sanitizer

and then execute "

nmake" to start compilation

After waiting for a few minutes (or 10 minutes), you should be able to find Release_TS in the php-src directory (Or Release_NTS or x64\Release_TS) Such a directory

If the compilation is normal, there will be a php.exe file below to prove that the php file is compiled successfully.

Run the compiled "php.exe - v" Check whether it is running normally

Note: Other command line configure parameters

--disable-cgi   编译出 windows 版本和 php-cgi.exe
--disable-zts   nts 非线程安全
--enable-shmop=shared   以dll 方式编译 php shmop 扩展

2. Compile judy extension

The successful compilation of the above php means that the php compilation environment is completed, now Start compiling judy extension

1.下载judy源码

http://pecl.php.net/package/judy  这里是php-judy 官网 但是这个源码好久没有更新了 最高只支持php5.6

https://github.com/esminis/php_pecl_judy  这个是github 上面 有用户升级过的php-judy 测试支持php7.2

根据 php_pecl_judy 的说明按如下步骤编译

2.编译judy.lib

到https://sourceforge.net/projects/judy/ 下载 源码 

解压到任意目录 

然后 在 judy-1.0.5\src\ 中右键 shift 点击 "在此处打开命令行窗口"  

运行 "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars32.bat" 注意路径可能不一样

然后运行 "build"

然后会编译出一个 judy.lib

3.拷贝judy.lib文件

一.重命名 judy.lib 文件为 "libJudy.lib" 复制到 D:\php_sdk\phpdev\vc15\x86\deps\lib\ 目录下

注释:也有可能是  D:\php_sdk\phpdev\vc15\x86\deps.xxxxxxx\lib\ 文件(看看哪个lib下面有 文件 就拷贝到哪个目录)

二.复制 judy.h 到deps\include 下面(同上 目录可能 为deps.xxxx )

4.复制 phpjudy(https://github.com/esminis/php_pecl_judy)源码到 php-src\ext\judy\

在 ext\judy\ 下面应该有文件


5.在刚刚编译php的cmd窗口执行 

configure --disable-all --enable-cli --enable-zlib --enable-hash --enable-session --without-gd --with-bz2 --with-judy=shared --enable-fd-setsize=2048 --enable-sanitizer


(如果关闭了 需要重新 执行 phpsdk-vc15-x86.bat 然后进入 php-src目录 执行 "build")

然后执行 nmake 然后就可以在 Release_TS 目录看见 php-judy.dll了(编译成功)

相关推荐:

PHP编译安装过程以及各编译参数配置详解

PHP7.1安装yaf扩展的方法


The above is the detailed content of Compile php7.2 under windows and extend judy. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn