Skip to main content

Build your own PHP on Windows

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

  • PHP officially supports building with Microsoft's Visual C++ compilers. 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 following VC versions are supported:
    • Visual C++ 9.0 (Visual Studio 2008 or Visual C++ 2008) for 5.4. You can use the Express versions as well.
    • Visual C++ 11.0 (Visual Studio 2012) for PHP 5.5+. You can use the Express versions as well.
  • If using VC9 or earlier, you will need the correct Windows SDK or Platform SDK to match your compiler. See this page for the supported versions.
  • Various tools, see http://windows.php.net/downloads/php-sdk/ for binary versions of them.

Setup

Quick 'n' Easy

  1. If compiling PHP 5.3 or 5.4:
    1. Install 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
  2. If compiling PHP 5.5+:
    1. Install Visual Studio 2012. If using the express version, install “Visual Studio 2012 Express for Windows Desktop
  3. Get PHP via git
  4. Create the folder “c:\php-sdk“
  5. Unpack the binary-tools.zip archive (http://windows.php.net/downloads/php-sdk/) into this directory, there should be one sub-directory called “bin” and one called “script“
  6. If compiling PHP 5.3 or 5.4:
    1. Open the “Windows SDK 6.1 shell” (it's available from the start menu group) and execute the following command in it:
      setenv /x86 /xp /release
  7. If compiling PHP 5.5+:
    1. Open “VS2012 x86 Native Tools Command Prompt” (it's available from the start menu group):
  8. Execute the following commands:
    cd c:\php-sdk\
    bin\phpsdk_setvars.bat
    bin\phpsdk_buildtree.bat phpdev
  9. If compiling for vc11:
    1. Copy c:\php-sdk\phpdev\vc9 to c:\php-sdk\phpdev\vc11 (the buildtree script hasn't been updated for vc11)
  10. Now extract the PHP source code to C:\php-sdk\phpdev\vcXX\x86 with your favorite unpacker (7-zip should handle it) where vcXX is the compiler version you are using. For example C:\php-sdk\phpdev\vc11\x86\<php-source-directory>
  11. In the same directory (C:\php-sdk\phpdev\vcXX\x86) there is a “deps” folder. Here you will need to extract all the libraries required to build PHP. We have packaged the required deps for most of the core extensions at http://windows.php.net/downloads/php-sdk/. Simply download the appropriate file that matches your PHP version and extract to C:\php-sdk\phpdev\vcXX\x86\deps
  12. Change directory to the location of your PHP source code:
    cd C:\php-sdk\phpdev\vcXX\x86\php-source-directory
  13. Run:
    buildconf
  14. To get an overview of the compiling flags:
    configure --help
  15. Create your configure command:
    configure --disable-all --enable-cli --enable-$remains
    1. Note: The deps located at http://windows.php.net/downloads/php-sdk/ should include the libraries needed to build most the core extensions. However, some other extensions may need additional libraries, header files and helper apps. See libs, fetch the version you need and extract the archive into the deps directory, i.e.: c:\php-sdk\phpdev\vcXX\x86\deps)
  16. Build PHP, run:
    nmake
  17. If you want the resulting PHP builds and extensions to be zipped, after 'nmake' also run:
    nmake snap
  18. The compiled PHP is now under “C:\php-sdk\phpdev\vcXX\x86\php-source-directory\Release_TS”. If you ran 'nmake snap' the zip file will also be here.
    1. If you compiled with “–disable-zts” the compiled PHP will be under “C:\php-sdk\phpdev\vcXX\x86\php-source-directory\Release”

Recompile after you have done some changes

  1. Clean up old compiled binaries
    nmake clean
  2. If you need to update the 'configure' script
    buildconf --force
  3. Create your makefile: see release
    configure --disable-all --enable-cli --enable-$remains
  4. Compile
    nmake

Adding PECL extensions (using 'dbase' as an example)

  1. cd C:\php-sdk\phpdev\vcXX\x86
  2. Get the dbase extension code through Subversion
  3. svn co http://svn.php.net/repository/pecl/dbase/trunk pecl/dbase
  4. cd php-source-directory
  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

LDAP Support Notes

  1. Add “–with-ldap” to your configure
  2. Make sure to package your generated binaries with libsasl.dll, which will not be built through this process - you can find it inside your C:\php-sdk\php53dev\vc9\x86\deps\bin\ folder, or you can download it from one of the PHP official binary packages

Pitfalls

fatal error C1900: [] mismatch between 'P1' version '200801116' and 'P2' version '20070207'
If you are using Visual Studio 2008 Express and Platform SDK 6.1 make sure you have the latest versions and check for version incompatibilities. There are known issues with old versions of VS 2008 Express and Platform SDK 6.1.
The order in which you install the Visual Studio 2008 Express Edition and Platform SDK 6.1 is important due to the issue reported in Windows SDK for Windows Server 2008 and .NET Framework 3.5 Overview, Windows SDK for Server 2008 (v6.1) overwrites VS2008 SP1 CRT files and Installing Windows SDK for Server 2008 (v6.1) after VS2008 SP1 causes conflicts with Security Update (KB971092). Install the SDK first, with any of its service packs and security updates before installing Visual Studio 2008 Express Edition.
Make sure that you are running setenv /xp /x86. For example, setenv /xp /x64 or setenv /vista /x64 causes the above error message even if you are using Visual Studio 2008 Express SP1 and Platform SDK 6.1 (60001.18000.367) on a Vista 64bit system.

Utilities

Resource Hacker

Utility to show dependency information and other assembly information from a DLL. For instance, it shows which version of the Visual C++ Runtime the DLL was linked against.
Get it here: http://angusj.com/resourcehacker/

internals/windows/stepbystepbuild.txt · Last modified: 2015/05/20 18:34 by pajoye

Comments

Popular posts from this blog

sxhkd volume andbrightness config for dwm on void

xbps-install  sxhkd ------------ mkdir .config/sxhkd cd .config/sxhkd nano/vim sxhkdrc -------------------------------- XF86AudioRaiseVolume         amixer -c 1 -- sset Master 2db+ XF86AudioLowerVolume         amixer -c 1 -- sset Master 2db- XF86AudioMute         amixer -c 1 -- sset Master toggle alt + shift + Escape         pkill -USR1 -x sxhkd XF86MonBrightnessUp          xbacklight -inc 20 XF86MonBrightnessDown          xbacklight -dec 20 ------------------------------------------------------------- amixer -c card_no -- sset Interface volume run alsamixer to find card no and interface names xbps-install -S git git clone https://git.suckless.org/dwm xbps-install -S base-devel libX11-devel libXft-devel libXinerama-devel  vim config.mk # FREETYPEINC = ${X11INC}/freetype2 #comment for non-bsd make clean install   cp config.def.h config.h vim config.h xbps-install -S font-symbola #for emoji on statusbar support     void audio config xbps-i

Hidden Wiki

Welcome to The Hidden Wiki New hidden wiki url 2015 http://zqktlwi4fecvo6ri.onion Add it to bookmarks and spread it!!! Editor's picks Bored? Pick a random page from the article index and replace one of these slots with it. The Matrix - Very nice to read. How to Exit the Matrix - Learn how to Protect yourself and your rights, online and off. Verifying PGP signatures - A short and simple how-to guide. In Praise Of Hawala - Anonymous informal value transfer system. Volunteer Here are five different things that you can help us out with. Plunder other hidden service lists for links and place them here! File the SnapBBSIndex links wherever they go. Set external links to HTTPS where available, good certificate, and same content. Care to start recording onionland's history? Check out Onionland's Museum Perform Dead Services Duties. Introduction Points Ahmia.fi - Clearnet search engine for Tor Hidden Services (allows you

download office 2021 and activate

get office from here  https://tb.rg-adguard.net/public.php open powershell as admin (win+x and a ) type cmd  goto insall dir 1.         cd /d %ProgramFiles(x86)%\Microsoft Office\Office16 2.           cd /d %ProgramFiles%\Microsoft Office\Office16 try 1 or 2 depending on installation  install volume license  for /f %x in ('dir /b ..\root\Licenses16\ProPlus2021VL_KMS*.xrm-ms') do cscript ospp.vbs /inslic:"..\root\Licenses16\%x" activate using kms cscript ospp.vbs /setprt:1688 cscript ospp.vbs /unpkey:6F7TH >nul cscript ospp.vbs /inpkey:FXYTK-NJJ8C-GB6DW-3DYQT-6F7TH cscript ospp.vbs /sethst:s8.uk.to cscript ospp.vbs /act Automatic script (windefender may block it) ------------------------------------------------------------------------------------------------------------------- @echo off title Activate Microsoft Office 2021 (ALL versions) for FREE - MSGuides.com&cls&echo =====================================================================================&