This article mainly introduces the compilation of PHP source code under Windows.
1.1 Compiling the environment
Software |
Environment |
Operating system |
Windows 7 Professional Edition 32bit |
Visual Studio |
2012 Professional Edition |
Php |
5.5.2.1 Thread-Safe version |
Php-sdk |
Download |
1.2 Compilation steps
This configuration step refers to the official PHP documentation.
1 Unzip the php-sdk file, put it in d:/php/php-sdk/respectively;
2 Open the VS2012 x86 native tool command prompt (which contains the path path of the VS compile, link, and so on command) under PHP-SDK, jump to the PHP-SDK directory and enter the command:
Bin\phpsdk_setvars.bat
Configure the inclusion path of the PHPSDK;
3 Running the command
Bin\phpsdk_buildtree.bat Phpdev
Get the build configuration php compile path, get Phpdev directory, the directory is VC6, VC8, VC9 three directories, respectively, corresponding to the compiler environment, directory content is as follows:
─vc9
├─x64
│└─deps
│├─bin
│├─include
│└─lib
└─x86
└─deps
├─bin
├─include
└─lib
4 the Vc9 folder in the Phpdev folder can be copied as VC11 because there is no compiled directory to generate vs2012 (VC11).
5 Unzip the PHP source into the D:\php\php-sdk\phpdev\vc11\x86 directory.
6 Running the command
Buildconf.bat
7 The command scans the path of all available packages and gets the configuration file configure.js.
8 Running the command
Configure.bat
This command configures the extensions that need to be installed, as well as the SAPI command. Help can use commands:
Configure.bat--help
The official advice is
Configure--disable-all--ENABLE-CLI
Where the CLI (command-line interface) is the command-line version of PHP, you can set the CGI, Apache module and other SAPI interface generation.
9 Running the command
NMAKE [Clean]
This command is similar to the Linux version of Make, which is the build tool for vs. Its makefile program is a file that ends with a mak. The clean parameter clears the build file.
If there is no error, the PHP.exe executable is generated under the Release_ts directory of the source directory. The program contains all of the configured modules, eliminating the need to manually add DLL libraries.
1.3 Possible problems
- Do not include CL, MC Program, need to reopen VS2012 x86 native tool command line prompt
- Bison, RE2C and other programs were not found. RE2C is a lexical parser used by PHP5.5, and Bison is a parser for the GNU project. Such programs are included in the Php-sdk/bin directory. Need to rerun command
Bin\phpsdk_setvars.bat
Add to.
- File encoding problem exists in extended calendar. Encode the Jewish.c file modified in the phpsource/ext/calendar/directory to utf-8. (Can be modified with notepad++)
- When compiling the Php5apache2_4 module, you need to download the apache2.4 and configure the include, LIB, and bin directories. This article is configured by adding a method for the user's include, lib, Bin (path Path) directory. The configuration method is similar to configuring the path path.
- When you configure the MYSQLNLD extension, there may be cases where zlib is not included. Can download zlib, compile, and put zlib DLL, Zlib.h zcon.h, lib file in Deps bin, include, Lib directory respectively.
Compilation of PHP source code