Unless you downloaded the source code as a tarball from php.net and compiled it yourself, however, you're most likely missing at least one component.
The first piece of equipment in any C developer's toolkit is an actual C compiler. There's a good chance your distribution included one by default, and a very good chance that it included gcc (GNU Compiler Collection). You can easily check whether or not a compiler is installed by issuing gcc version or cc version, one of which will hopefully run successfully and respond with version information for the compiler installed.
If you don't have a compiler yet, check with your distribution's website for instructions on downloading and installing gcc. Typically this will amount to downloading an .rpm or .deb file and issuing a command to install it. Depending on your specific distribution, one of the following commands may simply work out of the box without requiring further research: urpmi gcc, apt-get install gcc, pkg-add -r gcc, or perhaps emerge gcc.
In addition to a compiler you'll also need the following programs and utilities: make, autoconf, automake, and libtool. These utilities can be installed using the same per-distribution methods you used for gcc, or they can be compiled from their source using tarballs available from gnu.org.
For best results, libtool version 1.4.3 and autoconf 2.13 with automake version 1.4 or 1.5 are recommended. Using newer versions of these packages will quite probably work as well, but only these versions are certified.
If you plan on using CVS to check out the latest and most up-to-date version of PHP to develop with, you'll also need bison and flex for constructing the language parser. Like the others, these two packages may either be installed using your distribution's packaging system, or downloaded from gnu.org and compiled from source.
If you choose to go the CVS route, you'll also need the cvs client itself. Again, this may be installed by your distribution, or downloaded and compiled. Unlike the other packages, however, this one is found at cvshome.org.
The Win32/PHP5 build system is a complete rewrite and represents a significant leap forward from the PHP4 build system. Instructions for compiling PHP4 under Windows are available on php.net, only the PHP5 build systemwhich requires Windows 2000, Windows 2003, or Windows XPwill be discussed here.
First, you'll need to grab libraries and development headers used by many of the core PHP extensions. Fortunately, many of these files are redistributed from php.net as a single .zip file located at http://www.php.net/extra/win32build.zip.
Create a new directory named C:PHPDEV and unzip win32build.zip using your favorite zip management program into this location. The folder structure contained in the zip file will create a subdirectory, C:PHPDEVwin32build, which will contain further subfolders and files. It's not necessary to name your root folder PHPDEV; the only important thing is that win32build and the PHP source tree are both children of the same parent folder.
Next you'll need a compiler. If you've already got Visual C++ .NET you have what you need; otherwise, download Visual C++ Express from Microsoft at http://lab.msdn.microsoft.com/express/.
The installer, once you've downloaded and run it, will display the usual welcome, EULA (End-User License Agreement), and identification dialogs. Read through these screens and proceed using the Next buttons after you've agreed to the terms of the EULA and entered any appropriate information.
Installation location is of course up to you, and a typical installation will work just fine. If you'd like to create a leaner installation, you may deselect the three optional componentsGUI, MSDN, and SQL Server.
The final package is the Platform SDK, also available for download from Microsoft at http://www.microsoft.com/downloads/details.aspx?FamilyId=A55B6B43-E24F-4EA3-A93E-40C0EC4F68E5. The site currently lists three download options: PSDK-x86.exe, PSDK-ia64.exe, and PSDK-amd64.exe. These options refer to x86 compatible 32bit, Intel64bit, and AMD64bit processors respectively. If you're not sure which one applies to your processor, select PSDK-x86.exe, which should work cleanly, albeit less efficiently, with both 64 bit variants.
As before, proceed through the first few screens as you would with any other installer package until you are prompted to select between Typical and Custom installation. A Typical installation includes the Core SDK package, which is sufficient for the purposes of building PHP. Other packages can be deselected by choosing a Custom installation, but if you have the hard disk space to spare, you might as well install it all. The other packages may come in handy later on.
So unless you're byte conscious, select Typical and proceed through the next couple of standard issue screens until the installer begins copying and registering files. This process should take a few minutes so grab some popcorn.
Once installation is complete you'll have a new item on your Start menuMicrosoft Platform SDK for Windows Server 2003 SP1.
Obtaining the PHP Source Code
When downloading PHP, you have a few options. First, if your distribution supports the concept, you can download it from them using a command such as apt-get source php5. The advantage to this approach is that your distribution might have some known quirks that require modifications to the PHP source code. By downloading from them, you can be certain that these quirks have been patched for and your builds will have fewer issues. The disadvantage is that most distributions lag weeks, if not months, behind the official PHP releases, making the version you download outdated before it ever reaches your hard drive.
The next option, which is generally preferred, is to download php-x.y.z.tar.gz (where x.y.z is the currently released version) from www.php.net. This release of PHP will have been tested by countless other PHP users around the globe and will be quite up-to-date without pushing the absolute bleeding edge.
You could also go a small step further and download a snapshot tarball from snaps.php.net. On this site, the latest revisions of all the source code files in the PHP repository are packaged up every few hours. An accidental commit by a core developer might make one of these bundles unusable occasionally, but if you need the latest PHP 6.0 features before it has been officially released, this is the easier place to go looking.
Lastly, you can use CVS to fetch the individual files that make up the PHP source tree directly from the development repository used by the PHP core development team. For the purposes of extension and embedding development, this offers no significant advantage over using an official release tarball or a snapshot. However, if you plan to publish your extension or other application in a CVS repository, it will be helpful to be familiar with the checkout process.
Performing a CVS Checkout
The entire PHP project, from the Zend Engine and the core to the smallest PEAR component, is hosted at cvs.php.net. From here, hundreds of developers develop and maintain the bits and pieces that make up the whole of PHP and its related projects.
Among the other parts housed here, the core PHP package is available in the php-src module and can be downloaded to a workstation with two simple commands. First you'll want to introduce yourself to the php.net CVS server by logging in.
$ cvs -d:pserver:email@example.com:/repository login
The cvsread account is a public use (read-only) account with a password of phpfian homage to a much earlier version of what we know today as PHP. Once logged in, the PHP sources may be checked out using
$ cvs -d:pserver:firstname.lastname@example.org:/repository co php-src
Variations of this command can be used to check out specific versions of PHP going back as far as PHP2. For more information, refer to the anonymous cvs instructions at http://www.php.net/anoncvs.
The PHP Life Cycle
Variables from the Inside Out
Setting Up a Build Environment
Your First Extension
Working with Arrays and HashTables
The Resource Data Type
Startup, Shutdown, and a Few Points in Between
Diverting the Stream
Configuration and Linking
Setting Up a Host Environment
Appendix A. A Zend API Reference
Appendix B. PHPAPI
Appendix C. Extending and Embedding Cookbook
Appendix D. Additional Resources