One of the things I have done many times in the past year is setting up a build environment for PHP on Windows. I have been using a simple script to do this which I am releasing today with this blog. Here is the zip file contains the script winbuild.bat along with essential tools (wget and unzip) which the script requires. Before you run winbuild.bat, make sure Visual Studio (or VC9 expression edition) and TortoiseSVN are installed on the machine. If you do not have these already installed, you can install VC9 express edition from http://www.microsoft.com/express/downloads/ (select visual studio 2008 express) and TortoiseSVN from http://tortoisesvn.net/downloads. Installation of TortoiseSVN might require a reboot. Once machine is ready, download the attached zip, unzip files in a folder, say c:\winbuild, launch visual studio command prompt and then run c:\winbuild\winbuild.bat. By default this script will setup PHP 5.3 build environment in %systemdrive%\php\php_sdk\php_53_dev folder. If you want to choose a different branch and folder location, open winbuild.bat, change variable values on top of the script before running it. This script does the following for setting up the build environment.
· Create folder structure recommended here.
· Download and unzip binary tools package.
· Download and unzip all dependency libraries.
· Download php source code from http://svn.php.net.
· Run buildconf and configure commands.
After the script is complete, PHP root will be set to c:\php\php_sdk\php_53_dev\vc9\x86\PHP_5_3. If you change branch/folder locations in the script, this will be different. With the build environment set, you can now run “nmake snap” to build PHP in the PHP root folder. If you want to change configure options, open config.nice.bat (present in PHP root), change the options and run it. Running “nmake snap” will now build PHP using new configure options. Once the build is complete, release binaries will be under the release folder under php root.
Hope this makes setting PHP build environment much simpler. If you run into a bug in winbuild.bat, let me know by leaving a comment. Feature suggestions are also welcome.
Download script here.
Thanks.
Kanwal
Pingback: Webby Scripts Setting up PHP build environment on Windows « Kanwaljeet Singla
Pingback: Setting up PHP build environment on Windows « Kanwaljeet Singla « php
Pingback: Setting up PHP build environment on Windows « Kanwaljeet Singla
Pingback: Setting up PHP build environment on Windows « Kanwaljeet Singla
Pingback: Setting up PHP build environment on Windows « Kanwaljeet Singla : : windows
Pingback: Adding a PECL extension to your PHP build environment « Kanwaljeet Singla
Pingback: PHP PGO build for maximum performance on Windows « Kanwaljeet Singla
Hi,
I have somehoe a Problem with bison. Any clue?
C:\php_sdk\php_53_dev\vc9\x86\PHP_5_3>nmake snap
Microsoft (R) Program Maintenance Utility, Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.
bison.exe --output=Zend/zend_ini_parser.c -v -d -p ini_ Zend/zend_ini_pa
rser.y
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\bison.exe: c:/usr/loca
l/lib/bison.simple: No such file or directory
NMAKE : fatal error U1077: ""C:\Program Files (x86)\Microsoft Visual Studio 9.0\
VC\BIN\bison.exe"": Rückgabe-Code "0x2"
Stop.
Hi,
Everytime you launch Visual studio command prompt, you need to run c:\php_sdk\bin\phpsdk_setvars.bat. This will add c:\php_sdk\bin folder to path. This folder has bison.exe which is required for building PHP. I will add this detail in my blog.
Thanks,
Kanwal
Pingback: Anonymous
Pingback: Tune Up Your PC » Post Topic » This Week’s Link List (May 21, 2010)
Pingback: Work items collected from Tek-X « Kanwaljeet Singla
Hi,
I noticed something in your winbuild.bat script: After I ran it, things seems going well, but I saw a "phpsdk_servars.bat not found" likely message, and finally a "bison.exe not found" message.
Looking into the code I found at line 110 this instruccion: CALL phpsdk_servars.bat
I changed it by: CALL "%PHPROOT_BIN%\phpsdk_setvars.bat"
Then re-ran the batch and all things went smooth.
Regards.
Thanks for reporting this bug. I have made this change in the script.
Running winbuild.bat I get the following errors:
"WHERE" is not regognized as an internal or external command …
"cl.exe" not found. Please install Visual Studio …
This script was incredibly helpful. Thank you Kanwaljeet for taking the time to post it.
For those VS2008 newbies such as myself it is worth noting that when building on a Windows 7 64-bit OS, the shell you use when you set up and compile will determine if the PHP build is 64-bit or 32-bit. If it is 64-bit you need to modify the script to go grab the 64-bit extensions. In my case I wanted a 32-bit PHP build because I am targeting to a set of 32-bit servers. I attempted to use the "CMD Shell" shortcut under the Microsoft Windows SDK v6.1 programs menu. Using this shell gave me a 64-bit version of the PHP (assuming I didn't attempt to include any 32-bit extensions). The "Visual Studio 2008 Command Prompt" command prompt shortcut under "Microsoft Visual C++ 2008 Express Edition"->"Visual Studio Tools" allowed me to build for 32-bit.
Thanks again!
-Mark
Pingback: Rev it up with PHP and IIS | Josh Holmes
Tried this after struggling with getting al my dependencies in order. I get error "your build will be incomplete" "you do not have a snapshot template". Any ideas?
I tried your build, but no matter what I do, I still have the problem I had when I tried downloading all the various parts and dependencies myself. I get a "ordinal 57 not found in dynamic link library zlib1.dll" when I run php or php-cgi.exe. Any suggestions?
where you made this — CALL "%PHPROOT_BIN%\phpsdk_setvars.bat" — there is a typo. you have servars instead of setvars with a "t".
also, since your script zilb was updated from 1.2.3 to 1.2.5 in the libroot folder
thanks for the script
This tutorial is very much appreciated. The way it is explained is simply awesome. Anyways i have also seen a tutorial over a website that demonstrates how to install php on windows 7 with IIS 7 via FastCGI. For the users who want to host php with IIS 7, it will be great help for them
http://nice-tutorials.blogspot.com/2011/07/installing-php-on-windows-7-with-iis-7.html
If i understand this correctly, I do not need Windows SDK 6.1 to compile PHP?
I'm sory i know im a noobie on this one, but since i've started trying to compile my own php (with my own add-ons, modules loaded as static) I've kept getting some compiler errors. From weird to version mismatch etc., every thing i searched up on google didnt work out =) Im going to give your script a try, but i have a positive thought so far !
Anyway back to original question, since official php windows instructions tell you to get SDK, is it required at all?
Common error I'm getting: Command line error D8040 : error creating or communicating with child process
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\
VC\Bin\cl.exe"' : return code '0x2'
Any ideas? Sorry for double post by the way =(
There is a typo in setvar.dat. Second, the links for library downloads needs to be updated. The set up does not complete. Setting up manually. Please let me know when you update winbuild.dat. It will be nice for future versions.
Pingback: Installing PHP « Carra Lucia Ltd. Blog