internals:windows:stepbystepbuild

This is an old revision of the document!


Build your own PHP on Windows

Before you Begin

Building PHP on Windows will require three things

  1. A properly set up build environment, including a compiler with the right SDK's and some binary tools used by the build system
  2. Prebuilt libraries and headers for third party libraries that PHP uses in the correct location
  3. The PHP source

The Build Environment

This is the hardest part of the PHP windows build system to set up and will take up a lot of space on your hard drive - you need to have several GB of space free.

Requirements

  • Microsoft Visual C++, PHP officially supports building with Visual C++ 6.0 or with Visual C++ 9 (also known as Visual C++ 2008 just to be confusing). You can use the Express versions as well. MinGW and other compilers are NOT supported or even known to work. For more information and how to get the compiler see the supported versions
  • The correct Windows SDK or Platform SDK to match your compiler. see this page for the supported versions

Setup

Quick 'n' easy
  1. get visual studio 2008 (no matter what version - express, pro or others; all should work) and install it
  2. get and install windows sdk 6.1
  3. get a php 5.3 http://snaps.php.net/ (do not extract yet!)
  4. create the folder “c:\php-sdk“
  5. unpack the binary-tools.zip archive (http://pecl2.php.net/downloads/php-windows-builds/php-libs/) into this directory, there should be one sub-directory called “bin” and one called “script“
  6. open the “windows sdk 6.1 shell” (it’s available from the start menu group) and execute the following commands in it:
  7. setenv /x86 /xp /release
  8. cd c:\php-sdk\
  9. bin\phpsdk_setvars.bat
  10. bin\phpsdk_buildtree.bat php53dev
  11. now extract the snapshot from 3) to C:\php-sdk\php53dev\vc9\x86 with your favourite unpacker (winrar should handle it) so that the following directory gets created: C:\php-sdk\php53dev\vc9\x86\php5.3-xyz
  12. in the same directory (C:\php-sdk\php53dev\vc9\x86) there is a “deps” folder, extract any of your required libraries inside that folder (see http://wiki.php.net/internals/windows/libs) but make sure their top-level contains /include and /lib (some of them have an extra directory level in there)
  13. run in the windows-sdk-shell:
    cd C:\php-sdk\php53dev\vc9\x86\php5.3-xyz
  14. buildconf
  15. to get an overview of the compiling flags:
    configure --help
  16. create your configure command:
    configure --disable-all --enable-cli --enable-$remains

    (warning: some extensions need libraries, header files and helper apps, see libs, fetch the version you need and extra the archive in the deps directory, ie: c:\php-sdk\php53\vc9\x86\deps)

  17. nmake
  18. if you want the resulting php to be zipped (comes handy for redist, believe me!), run after this also:
    nmake snap
  19. the compiled php is now under C:\php-sdk\php53dev\vc9\x86\php5.3-SNAPSHOTTIME\Release_TS, same as the zip file (if you created it).
Adding PECL extensions (using 'dbase' as an example)
  1. cd C:\php-sdk\php53dev\vc9\x86
  2. get the dbase extension code through Subversion
  3. svn co http://svn.php.net/repository/pecl/dbase/trunk pecl/dbase
  4. cd php5.3-xyz
  5. buildconf
  6. executing
    configure --help

    should now contain a dbase option

  7. configure --enable-cli --enable-dbase
  8. nmake
  9. test the binary with a
    php -m

    command, to make sure dbase exists

internals/windows/stepbystepbuild.1281726376.txt.gz · Last modified: 2017/09/22 13:28 (external edit)