In my quest to learn php extension development, I have been told I need to compile PHP from source. Given that it was a bit tricky, I thought I would document it here because chances are I'll need to refer back to this at some point. I did all of this on my Win XP machine. Details may vary on different OS versions. This is based largely on this wiki.
The following steps resulted in a build using Windows SDK 6.1.
1) Download and install Visual C++ Express. I used VC2008 Express:
http://www.microsoft.com/express/downloads/
2) Download and install Windows SDK 6.1.
3) Create a folder to put everything in. I used C:\php-sdk so that's what I'll refer to in the following steps.
4) Download and unpack the PHP Binary Tools Archive into C:\php-sdk. Make sure you see a bin and script folder in there.
5) Open the 6.1 SDK's CMD shell. I did this by selecting Start -> All Programs -> Microsoft Windows SDK v6.1 -> CMD Shell.
6) set some env vars:
setenv /x86 /xp /release
7) CD to this dir. Note I had to use the /d flag for some reason to get the cd command to work. You may or may not need it.
cd /d c:\php-sdk\
8) Set some vars:
bin\phpsdk_setvars.bat
9) build a directory tree:
bin\phpsdk_buildtree.bat php53dev
If this command complains, try creating the directory C:\php-sdk\php53dev[/code] first.
10) Download the PHP source you'd like to compile and extract it in C:\php-sdk\php53dev\vc9\x86. I downloaded my source from the link at the top of this page. DO NOT BOTHER with the binaries. Just get the source. The resulting folder should be something like C:\php-sdk\php53dev\vc9\x86\php-5.3.X
11) You need to fetch some code libraries that PHP uses and put them in the deps folder located at C:\php-sdk\php53dev\vc9\x86\deps. Rather than building them yourself, I recommend you download them from this page. Note that page may list more than one version of a given library. Get the latest one. I downloaded them all and saved the zip archives in my deps folder and unzipped them there. Each zip archive should contain a bin, lib, and maybe an include folder so make sure when you extract them into the deps folder that they should put their contents in the lib/bin/include folder there rather than in some other folder name.
12) In the CMD Shell window, change dirs again:
cd /d C:\php-sdk\php53dev\vc9\x86\php5.3-X
Again, I had to use the /d flag to get this to work. you may be able to leave it out.
13) In the CMD Shell, execute this command:
buildconf
14) To get an idea of what your config options are, type this in the CMD Shell:
configure --help
15) I chose this configuration and it seems to work. CMD Shell:
configure --enable-apache2-2handler --with-curl --enable-fileinfo --enable-mbstring --enable-mbregex --with-mcrypt --with-openssl --with-pgsql --enable-sockets --with-mysql --with-mysqli --enable-pdo --with-pdo-mysql --with-pdo-mssql --with-pdo-pgsql --enable-soap --with-xmlrpc --with-xsl
16) make the project. this should take some time. CMD Shell:
nmake
if you have problems, try this as it will remove old stuff and try to make everything all fresh. CMD Shell:
nmake clean all
17) if you want the resulting php to be zipped for redist, run this too:
nmake snap
18) the compiled php EXEs and DLLs are now under C:\php-sdk\php53dev\vc9\x86\php5.3-X\Release_TS.
You can try running the newly compiled version of PHP. NOTE that if you had php installed previously, you need to type the complete path to the new PHP.exe or you'll just be interacting with your previously installed version. Also, the newly compiled php doesn't find an INI file so you need the -n flag. Try this:
C:\php-sdk\php53dev\vc9\x86\php-5.3.3\Rele
ase_TS\php.exe -n -i | more
This lets you page through the output of phpinfo() by hitting the space bar.
That's it for now. I'm not really sure how to install this just yet. There are some useful tips for setting your path and file assocations here and hereHints and tips are welcome.