Sunday, May 06, 2012

Compile PHP binary with Lua extension on Windolws 7

  1. download and install Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1 
  2. download PHP source code (php-5.3.11.tar.bz2) from:
  3. download PHP SDK ( from:
  4. download PHP Dependable libs (deps-5.3-vc9-x86.7z) from:
  5. download PHP PECL Lua extension source code (lua-0.9.4.tgz) from:
  6. download and install Lua 5.1 from
    install Lua at C:\Lua
  7. create a directory at C:\php-sdk, unzip the into this directory
  8. open Microsoft Windows SDK v7.0 CMD Shell
  9. enter those commands below:
    setenv /x86 /win7 /Release
    cd C:\php-sdk
    bin\phpsdk_buildtree.bat php-5.3.11
  10. unzip php-5.3.11.tar.bz2 into C:\php-sdk\php-5.3.11\vc9\x86\php-5.3.11
  11. create a directory at C:\php-sdk\php-5.3.11\vc9\x86\deps, unzip deps-5.3-vc9-x86.7z into this directory
  12. create a directory at C:\php-sdk\php-5.3.11\vc9\x86\pecl, unzip lua-0.9.4.tgz into C:\php-sdk\php-5.3.11\vc9\x86\pecl\lua
  13. back to Microsoft Windows SDK v7.0 CMD Shell, and enter those commands below:
    cd C:\php-sdk\php-5.3.11\vc9\x86\php-5.3.11
    configure --disable-zts --enable-snapshot-build --with-lua=C:\Lua\5.1
    nmake snap
  14. go to the directory C:\php-sdk\php-5.3.11\vc9\x86\php-5.3.11\Release, you can get the PHP Winodows Binaries: and
  15. enjoy to use the binaries!

  1. "ext\calendar\jewish.c(324) : error C2001: newline in constant": open two files: jewish.c and calendar.c, re-save them with UTF-8 encoding.
  2.         cd Release\php-5.4.7
            ..\..\..\..\bin\zip.exe -9 -q -r ..\ .
    The system cannot find the path specified.
            cd ..\..
            cd Release\pecl-5.4.7
            ..\..\..\..\bin\zip.exe -9 -q -r ..\ .
    The system cannot find the path specified.
            cd ..\..
            cd Release\php-test-pack-5.4.7
            ..\..\..\..\bin\zip.exe -9 -q -r ..\ .
    The system cannot find the path specified.
            cd ..\..
            cd Release
            ..\..\..\..\bin\zip.exe -9 -q *.pdb
    The system cannot find the path specified.
            ..\..\..\..\bin\zip.exe -9 -q -r php-5.4.7-devel-VC9-x86
    The system cannot find the path specified.
            cd ..\..

    open Makefile, added a line as below after "PHP_SRC_DIR =C:\php-sdk\php-5.3.11\vc9\x86\php-5.3.11":
  1. There is no php_lua.dll.
    The lua extension is static only.

reference1: Build your own PHP on Windows
reference2: Windows 中编译 PHP5.4 + xdebug
reference3: /dev/php/php-on-windows
pre-build DLLs:

1 comment:

Anonymous said...

Can you post somewhere your compiled build or just compiled php_lua.dll? I tried to make all the instructions, but there is an error no the last step that I can't solve:

Release\php.exe -d date.timezone=UTC -n -dphar.readonly=0 win32/build/mk
dist.php "Release" "C:\php-sdk\php-5.3.13\vc9\x86\deps" "php5.dll" "php-cgi.exe
php.exe php-win.exe php5embed.lib" "php_bz2.dll php_curl.dll php_enchant.dll php
_fileinfo.dll php_gd2.dll php_gettext.dll php_gmp.dll php_imap.dll php_interbase
.dll php_intl.dll php_ldap.dll php_mbstring.dll php_openssl.dll php_pgsql.dll ph
p_shmop.dll php_snmp.dll php_sockets.dll php_sqlite3.dll php_sybase_ct.dll php_t
idy.dll php_exif.dll php_mysql.dll php_mysqli.dll php_pdo_firebird.dll php_pdo_m
ysql.dll php_pdo_odbc.dll php_pdo_pgsql.dll php_pdo_sqlite.dll php_soap.dll php_
sqlite.dll php_xmlrpc.dll php_xsl.dll " " " "no"
NMAKE : fatal error U1077: 'Release\php.exe' : return code '0xc0000135'