|
Building from sourceThis chapter teaches how to compile PHP from sources on windows, using Microsoft's tools. To compile PHP with cygwin, please refer to Chapter 2, Installation on Unix systems. To compile and build PHP you need a Microsoft Development Environment. Microsoft Visual C++ 6.0 is recommended, though Visual C++ .NET versions will also work. Since PHP 5 the free Microsoft .NET toolchain is also supported (you need to install Windows Platform SDK, Visual C++ Toolkit and .NET Framework SDK). To extract the downloaded files you will also need a ZIP extraction utility. Windows XP and newer already include this functionality built-in. Before you get started, you have to download:
Finally, you are going to need the source to PHP itself. You can get the latest development version using » anonymous CVS, a » snapshot or the most recent released » source tarball. After downloading the required packages you have to extract them in a proper place:
Following this steps your directory structure looks like this: +--C:\work
If you aren't using » Cygwin, you must also
create the directories
Note:
If you want to use PEAR and the comfortable command line installer, the CLI-SAPI is mandatory. For more information about PEAR and the installer read the documentation at the » PEAR website.
You must build the
At this point, you should have a usable This chapter explains how to compile PHP >=5 using the new build system, which is CLI-based and very similar with the main PHP's Unix build system.
Note:
This build system isn't available in PHP 4. Please refer to the section called “Building PHP using DSW files [PHP 4]” instead. Before starting, be sure you have read the section called “Putting it all together” and you have built all needed libraries, like » Libxml or » ICU (needed for PHP >= 6). First you should open a Visual Studio Command Prompt, which should be available under the Start menu. A regular Command Prompt window shouldn't work, as probably it doesn't have the necessary environment variables set. Then type something like cd C:\work\php-5.x.x to enter in the PHP source dir. Now you are ready to start configuring PHP.
The second step is running the buildconf batch file to
make the configure script, by scanning the folder for
The third step is configuring. To view the list of the available
configuration options type cscript /nologo configure.js
--help. After choosing the options that you will enable/disable,
type something like: cscript /nologo configure.js --disable-foo
--enable-fun-ext. Using
The last step is compiling. To achieve this just issue the command
nmake. The generated files (e.g. .exe and .dll) will be
placed in either Optionally you may also run PHP's test suite, by typing nmake test. If you want to run just a specific test, you may use the 'TESTS' variable (e.g. nmake /D TESTS=ext/sqlite/tests test - will only run sqlite's tests). To delete the files that were created during the compilation, you can use the nmake clean command.
A very useful configure option to build snapshots is
Compiling PHP using the DSW files isn't supported as of PHP 5, as a much more flexible system was made available. Anyway, you can still use them, but keep in mind that they are not maintained very often, so you can have compiling problems. To compile PHP 4 for windows, this is the only available way though. The first step is to configure MVC++ to prepare for compiling. Launch Microsoft Visual C++, and from the menu select Tools => Options. In the dialog, select the directories tab. Sequentially change the dropdown to Executables, Includes, and Library files. Your entries should look like this:
The best way to get started is to build the CGI version:
It is possible to do minor customization to the build process by editing
the
Next you may want to build the CLI version which is designed to use PHP from the command line. The steps
are the same as for building the CGI version, except you have to select
the
In order to build the SAPI module ( Code Examples / Notes » install.windows.buildingzbowden
When running "cscript /nologo configure.js" 5.x on Windows 2000 or XP, if you get the following error: Microsoft JScript runtime error: Object doesn't support this property or method You need to have at least version 5.6 of WSH. This is necessary because configure.js will use the .Exec() method of the WScript.Shell. This evidently didn't exist until 5.6? You can download WSH 5.6 here: http://www.microsoft.com/downloads/details.aspx? FamilyID=c717d943-7e4b-4622-86eb-95a22b832caa&DisplayLang=en c-reaction.net - software development
Don't forget to setup Environment variable: BISON_SIMPLE="C:\\work\\win32build\\bin\\bison.simple" or this can cause error: c:/usr/local/lib/bison.simple: No such file or directory Alexey Furmanov. 26-jan-2005 12:30
Compiling using Visual Studio .NET will create binaries dependent of msvcp71.dll which has three repercussions: 1. This dll will need to be distributed. 2. The binaries are not currently compatible with the Zend optimiser (not sure why it should make a difference but it does). 3. Binaries are larger! giunta dot gaetano
A detailed tutorial for building php 5 using VC++ 2005 express edition (ie. the free version) is available here: http://elizabethmariesmith.com/2006/11/15/ It can be a huge time saver if you do not have a complete VC6 toolchain already setup axel
>>Compiling using Visual Studio .NET will create binaries dependent of msvcp71.dll > > Only if you compile with the wrong runtime library. if this is so easy, please tell us how you managed to *not* create dependencies on msvcp71.dll/msvcr80/... using Visual C++ .NET 2000/2003/2005. thanks! 10-dec-2006 02:09
>> Compiling using Visual Studio .NET will create binaries dependent of msvcp71.dll Only if you compile with the wrong runtime library. |
Change LanguageWindows Installer (PHP 5.2 and later) Windows Installer (PHP 5.1.0 and earlier) Manual Installation Steps ActiveScript Microsoft IIS / PWS Apache 1.3.x on Microsoft Windows Apache 2.0.x on Microsoft Windows Sun OmniHTTPd Server Sambar Server on Microsoft Windows Xitami on Microsoft Windows Building from source Installation of extensions on Windows |