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
- A properly set up build environment, including a compiler with the right SDK's and some binary tools used by the build system
- Prebuilt libraries and headers for third party libraries that PHP uses in the correct location
- 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
- Various tools, see http://pecl2.php.net/downloads/php-windows-builds/php-libs/binary-tools.zip for binary versions of them
Setup
Quick 'n' easy
- get visual studio 2008 (no matter what version - express, pro or others; all should work) and install it
- get and install windows sdk 6.1
- get a php 5.3 snapshot (do not extract yet!)
- create the folder “c:\php-sdk“
- 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“
- open the “windows sdk 6.1 shell” (it’s available from the start menu group) and execute the following commands in it:
setenv /x86 /xp /release
cd c:\php-sdk\
bin\phpsdk_setvars.bat
bin\phpsdk_buildtree.bat php53dev
- 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
- 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)
- run in the windows-sdk-shell:
cd C:\php-sdk\php53dev\vc9\x86\php5.3-xyz
buildconf
- to get an overview of the compiling flags:
configure --help
- 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)
nmake
- if you want the resulting php to be zipped (comes handy for redist, believe me!), run after this also:
nmake snap
- 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)
cd C:\php-sdk\php53dev\vc9\x86
- get the dbase extension code through Subversion
svn co http://svn.php.net/repository/pecl/dbase/trunk pecl/dbase
cd php5.3-xyz
buildconf
- executing
configure --help
should now contain a dbase option
configure --enable-cli --enable-dbase
nmake
- test the binary with a
php -m
command, to make sure dbase exists
internals/windows/stepbystepbuild.1272212106.txt.gz · Last modified: 2017/09/22 13:28 (external edit)