Compiling PHP on Windows

Created by: Lester Caine, Last modification: 02 Sep 2011 (21:53 BST)

Expanding on the notes provided on 'harddrive is a'

Initial Install

  1. Get Visual Studio 2008 (no matter what version - express, pro or others; all should work) and install it - The free version is available at Microsoft Express Download
    First go to the Visual Studio 2008 page from the top bar, 2010 version is useable but not supported, however the current free download only has the x86 compiler.
    Select the C++ download which will pull over the web based downloader.
    Run the downloader file which will take some time to complete and may appear to stop for an hour or so at a time until everything is download.
    All we actually need from this 1Gb+ download is the C compiler - Private setup has archived copy of necessary files.
  2. Get and install windows sdk 6.1 SDK 7.1 not yet supported.
    Installing this to C:\Network\Windows\V6_1 keeps thing in line with the rest of the network development software.
  3. Get a php 5.3 snapshot (do not extract yet!) Add links to SVN and source - want to link this to Eclipse for code management
  4. create the folder “c:\Network\php-sdk“
  5. unpack this archive into this directory, there should be one sub-directory called “bin” and one called “script“.
  6. An additional package of scripts tidies things up a little more  - Helper Scripts
    These are copied to the C:\Network\Windows\V6_1 and wrap the normal scripts into single steps.
  7. open the “Microsoft Windows SDK 6.1->CMD Shell”
  8. phpsetblank {target}
  9. now extract the snapshot from 3) to C:\Network\php-sdk\{target}\vc9\x64 with your favourite unpacker so that the following directory gets created: C:\php-sdk\{target}\vc9\x64\php5.3-xyz
  10. run in the windows-sdk-shell:
  11. cd C:\php-sdk\{target}\vc9\x86\php5.3-xyz
  12. buildconf
  13. configure --help, to get an overview of the compiling flags
  14. configure --disable-all --enable-apache2-2handler --enable-debug
    ( For NTS build add --diable-zts to the command line )
  15. nmake

Compile an extension

  1. Open a new “Microsoft Windows SDK 6.1->CMD Shell” Command Prompt
  2. phpset64
  3. cd C:\php-sdk\{target}\vc9\x86\php5.3-xyz
  4. buildconf ( To add any new extension directories to the configure file )
  5. configure --disable-all --enable-cli --with-{extension}=shared
    ( For NTS build add --diable-zts to the command line )
  6. nmake