您好,登錄后才能下訂單哦!
PHP 7出來后,http://pecl.php.net/package/memcache上沒有for PHP7的PHP-memcache版本,需要自己編譯一個。網上找到的大多是在linux下的,而我需要的是windows下的版本,找了好久沒也沒有找到合適的版本,只好自己動手了。
注:本文講的是編譯PHP-memcache,而不是memcached。
編譯前需要子下載如下文件:
1、 編譯環境:
PHP 7是用VC14編譯的,因此編譯PHP-memcached也需要使用VC14,因為并不常用VC14,所以到微軟的官網上下載visual studio 2015 entrpise的試用版即可。
2、 PHP源代碼:
從PHP官網上下載源代碼,地址:http://windows.php.net/downloads/releases/php-7.0.6-src.zip
3、 下載PHP-SDK文件:
地址:http://windows.php.net/downloads/php-sdk/
在這里要下載兩個文件:
4、 下載memcache擴展包的源碼:
地址:https://github.com/websupport-sk/pecl-memcache
PHP memcache官網已經N年沒有更新了,上面這個網址是github上的支持PHP 7的分支代碼。
1、 創建一個用于編譯的目錄:D:\PHPCompile;
2、 解壓php-sdk-binary-tools-20110915.zip里面的文件到PHPCompile目錄下;
3、 編輯“D:\PHPCompile\bin\phpsdk_buildtree.bat”,在“GOTO EXIT”前增加代碼:
MD %_%\vc14\x86\deps\bin
MD %_%\vc14\x86\deps\lib
MD %_%\vc14\x86\deps\include
MD %_%\vc14\x64\deps\bin
MD %_%\vc14\x64\deps\lib
MD %_%\vc14\x64\deps\include
注:這是因為phpsdk_buildtree.bat年代久遠,還不支持VC14,因此需要進行如此修改。
4、 在開始菜單找到并打開“VS2015 x64 本機工具命令提示符”(注:如果要編譯32位的,則需進入VS2015 x86 本機工具命令提示符),進入到D:\PHPCompile目錄下,然后執行如下命令:
bin\phpsdk_setvars.bat
bin\phpsdk_buildtree.bat phpdev
5、 執行后,目錄下會生成phpdev文件夾;
6、 進入D:\PHPCompile\phpdev\vc14\x64\,把deps-7.0-vc14-x64.7z解壓到該目錄下,覆蓋deps文件夾
7、 把php源代碼也解壓到x64目錄下,將解壓后的目錄名改為PHP7;
8、 在x64目錄下創建pecl文件夾,在該文件夾下再建立memcache文件夾,將下載的PHP7-memcache代碼解壓到這個目錄下,最終的目錄結構如下:
9、 執行以下命令,用于創建php編譯配置:
cd phpdev\vc14\x64\php7
buildconf
configure --help >..\configure_help.txt
configure --disable-all --enable-cli --enable-zlib --enable-hash --enable-session --without-gd --with-bz2 --enable-memcache=shared --enable-object-out-dir=..\obj
注:配置中的--enable-memcache=shared意思是 memcache 以 dll 形式生成,否則就和php集成在一起了。
如果提示bison.exe不存在,執行如下命令,再重新執行上面的操作:
set path=%path%;D:\PHPCompile\bin
10、 Configure命令執行成功后如下,實際開始編譯前最好檢查下參數是否有問題:
snapshot: forcing one-shot on snapshot: forcing debug-pack on snapshot: forcing --disable-security-flags shared snapshot: forcing analyzer on snapshot: forcing --without-uncritical-warn-choke shared snapshot: forcing codegen-arch on snapshot: forcing apache2handler on snapshot: forcing apache2-2handler on snapshot: forcing apache2-4handler on snapshot: forcing cli-win32 on snapshot: forcing embed on snapshot: forcing phpdbg on snapshot: forcing phpdbgs on snapshot: forcing --disable-phpdbg-webhelper shared snapshot: forcing bz2 on snapshot: forcing curl on snapshot: forcing dba on snapshot: forcing enchant on snapshot: forcing fileinfo on snapshot: forcing ftp on snapshot: forcing --without-libwebp shared snapshot: forcing gettext on snapshot: forcing gmp on snapshot: forcing mhash on snapshot: forcing imap on snapshot: forcing interbase on snapshot: forcing intl on snapshot: forcing ldap on snapshot: forcing libmbfl on snapshot: forcing mbstring on snapshot: forcing mbregex on snapshot: forcing --disable-mbregex-backtrack shared snapshot: forcing mcrypt on snapshot: forcing oci8 on snapshot: forcing oci8-11g on snapshot: forcing oci8-12c on snapshot: forcing odbc on snapshot: forcing --disable-opcache-file shared snapshot: forcing openssl on snapshot: forcing pgsql on snapshot: forcing pspell on snapshot: forcing shmop on snapshot: forcing snmp on snapshot: forcing sockets on snapshot: forcing sqlite3 on snapshot: forcing sysvshm on snapshot: forcing tidy on snapshot: forcing exif on snapshot: forcing mysqli on snapshot: forcing pdo on snapshot: forcing pdo-dblib on snapshot: forcing pdo-mssql on snapshot: forcing pdo-firebird on snapshot: forcing pdo-mysql on snapshot: forcing pdo-oci on snapshot: forcing pdo-odbc on snapshot: forcing pdo-pgsql on snapshot: forcing pdo-sqlite on snapshot: forcing pdo-sqlite-external on snapshot: forcing phar-native-ssl on snapshot: forcing soap on snapshot: forcing xmlrpc on snapshot: forcing xsl on Saving configure options to config.nice.bat Checking for cl.exe ... Detected compiler MSVC14 (Visual C++ 2015) Detected 64-bit compiler Checking for link.exe ... C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64 Checking for nmake.exe ... Checking for lib.exe ... Checking for bison.exe ... Checking for re2c.exe ... Detected re2c version 0.13.5 Checking for zip.exe ... Checking for lemon.exe ... Checking for mc.exe ... C:\Program Files (x86)\Windows Kits\8.1\bin\x64 Checking for mt.exe ... C:\Program Files (x86)\Windows Kits\8.1\bin\x64 Enabling multi process build
Build dir: D:\PHPCompile\phpdev\vc14\x64\obj\Release_TS PHP Core: php7ts.dll and php7ts.lib
Checking for wspiapi.h ... Enabling IPv6 support Enabling SAPI sapi\cgi Enabling SAPI sapi\cli Enabling extension ext\date Enabling extension ext\pcre Enabling extension ext\reflection Enabling extension ext\session Enabling extension ext\spl Checking for timelib_config.h ... ext/date/lib Enabling extension ext\standard Enabling extension ..\pecl\memcache [shared]
Creating build dirs... Generating files... Generating Makefile Generating main/internal_functions.c [content unchanged; skipping] Generating main/config.w32.h Generating phpize Done.
Enabled extensions: ----------------------- | Extension | Mode | ----------------------- | date | static | | memcache | shared | | pcre | static | | reflection | static | | session | static | | spl | static | | standard | static | -----------------------
Enabled SAPI: ------------- | Sapi Name | ------------- | cgi | | cli | -------------
---------------------------------------------- | | | ---------------------------------------------- | Build type | Release | | Thread Safety | Yes | | Compiler | MSVC14 (Visual C++ 2015) | | Architecture | x64 | | Optimization | PGO disabled | | Static analyzer | disabled | ----------------------------------------------
Type 'nmake snap' to build a PHP snapshot
D:\PHPCompile\phpdev\vc14\x64\php7> |
11、 執行nmake命令,等待十幾分鐘,如果沒有問題就會編譯成功,如果有問題,呵呵,那就要根據錯誤信息一點點排查解決了;
12、 編譯成功后,可在“D:\PHPCompile\phpdev\vc14\x64\obj\Release_TS\”目錄下找到php_memcache.dll;
安裝很簡單,將php_memcache.dll解壓到PHP的EXT目錄下即可。
打開PHP.INI,在一堆extension配置項中另起一行,輸入:
extension=php_memcache.dll
重啟Apache服務器后,在瀏覽器中打開http://localhost/phpinfo.php,搜索memcache,看到如下內容就說明安裝成功了:
https://wiki.php.net/internals/windows/stepbystepbuild#building_pecl_extensions
http://blog.csdn.net/mycwq/article/details/10165955
https://bugs.php.net/bug.php?id=70751
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。