Chuyển đến nội dung chính

[PHP] How to compiled PHP 5.4 Extension in Windows

Trước khi thực hiện, bạn phải chắc là máy bạn đã cài visual studio 2008 & Windows SDK 6.1 (Windows SDK for Windows Server 2008 & .Net framework 3.5 (link tải)


- Download php_sdk và deps từ địa chỉ http://windows.php.net/downloads/php-sdk/
- Download mã nguồn PHP từ github: https://github.com/php/php-src/tree/PHP-5.4.35



Giải nén thư mục php-sdk, đặt vào biến môi trường để gõ cho tiện.Ví dụ tôi giải nén thư mục php-sdk tại ở E thì thêm đường dẫn E:\php-sdk\bin vào biến PATH.


Tạo thư mục C:\php
Từ start menu, chọn All Programs, tìm đến Microsoft Windows SDK 6.1, bật CMD Shell lên.
Gõ lệnh: 
cd C:\php
Tiếp đến gõ lệnh:
setenv /x86 /xp /release
 
Các tùy chọn: 
- x86: win32
- xp: chọn Windows XP là target
- release: Bản realease
 
Gõ lệnh: phpsdk_setvars.bat
Gõ tiếp: phpsdk_buildtree.bat phpdev
 
Vào thư mục C:\php, bạn sẽ thấy thư mục C:\php\phpdev
Bên trong sẽ có các thư mục vc6, vc8, vc9, copy vc9 -> vc11
trong mỗi thư mục sẽ có thư mục x86 hay x64.
 
Giải nén source code php vào thư mục C:\php\phpdev\vc9\x86
Giải nén toàn bộ thư mục deps vào C:\php\phpdev\vc9\x86
 
Có thể tải các extension từ pecl, tạo thư mục pecl ngang cấp với thư mục deps & thư mục php-src

Di chuyển đến thư mục php-src. Gõ lệnh buildconfig. Bạn sẽ gặp lỗi sau
Input Error: There is no script engine for file extension ".js".
 
 Edit file buildconfig.bat
cscript /nologo win32\build\buildconf.js %* 
thành 
cscript /nologo /e:jscript win32\build\buildconf.js %*

Gõ lại lệnh buildconfig ta được file configure.bat mới. Tiếp tục sửa file configure.bat, thêm tham số /e:jscript

Gõ lệnh configure --help để biết các extension hỗ tr

Gõ configure --enable-snapshot-build --disable-debug --enable-zts --enable-apache2-4handler --enable-apache2-2handler --enable-apache2filter --enable-apache2-2filter --disable-cgi --enable-cli --disable-crt-debug --disable-isapi --disable-nsapi --with-curl --without-ereg --enable-fileinfo --with-gd --without-t1lib --with-gettext --with-mhash --enable-mbstring --with-m
crypt --with-openssl --enable-apc --with-imagick --enable-pdo --with-xdebug=shared --with-pdo-mysql  --with-mysql --with-xmlrpc --with-mysqli



Sau đó gõ nmake snap.

Chờ chương trình compile xong, và kết quả bạn thu được là bản PHP nằm trong thư mục Release_TS

 Tham khảo: 
  1. https://wiki.php.net/internals/windows/stepbystepbuild
  2. http://www.bowu.org/php/build-php-from-source-with-pecl-extensions.html
  3. http://www.sitepoint.com/compiling-php-from-source-on-windows/  
 

Nhận xét

Bài đăng phổ biến từ blog này

Windows 10 enable long file/folder path

Windows 10 enable long file/folder path Registry Import Enabling Long Paths Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\FileSystem] "LongPathsEnabled"=dword:00000001 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem] "LongPathsEnabled"=dword:00000001 Enable via group policy editor Local Computer Policy -> Computer Configuration -> Administrative Templates -> System -> FileSystem -> Double click Enable Win32 long paths and select Enabled

[Solved] Adobe Premiere Pro CC 2015 has stopped on Windows 10 x64 (card AMD)

First you can check yours graphic card fully support Adobe Premiere Pro CC 2015 at here: http://blogs.adobe.com/premierepro/2013/05/improved-gpu-support-in-adobe-premiere-pro-cc.html If you open "Configure Switchable Graphics", you'll see the adobe premiere pro.exe has been locked. By default, it only run on Intel graphics, so you cant change or unlock this. To make your Adobe Premiere Pro CC 2015 run on AMD Graphics card, just rename file Adobe Premiere Pro.exe into Adobe Premiere Pro CC.exe After rename, run application again, and open Configure Switchable Graphics and choose High Performance. See this thread for more information: https://community.amd.com/thread/167905