Home  >  Article  >  Backend Development  >  How to compile the source code of php and xdebug on windows

How to compile the source code of php and xdebug on windows

WBOY
WBOYOriginal
2016-08-08 09:28:321055browse

There are many introductions to php source code compilation on the Internet, but there are almost no introductions to xdebug source code compilation. I will talk about it based on my actual operation, which will also involve the compilation of apache source code.

1. PHP compilation

We use vs2008 as the compilation tool; others also need PHP compilation kit, which can be downloaded from the PHP official website http://windows.php.net/downloads/php-sdk/, download this Bar:

php-sdk-binary-tools-20110915.zip

Assume it is released to the e:php-sdk directory

Enter command-line mode from the start menu:

Configure the vs2008 environment first. Enter the installation path of 2008 in naming mode, assuming it is c:program filesmicorosft visual studio v9.0; then enter the vc subdirectory under this directory again:

cd vc

c:program filesmicorosft visual studio v9.0vc This When executing vcvarsall.bat

c:program filesmicorosft visual studio v9.0vcvcvarsall.bat

this way the 2008 execution environment is established.

The next step is to enter the php-sdk directory,

e:php-sdk

Execute

binphpsdk_setvars.bat

Then execute:

binphpsdk_buildtree.bat phpdev

This will be created in the current directory There is a subdirectory phpdev. We put the downloaded php source code under its subdirectory vc9/x86. Taking 5.4.73 as an example, the directory will look like this:

e:php-sdkphpdevvc9/x86/ php-5.4.37

Enter the php-5.4.37 directory and execute

buildconf

The configure.bat and configure.js files will be generated

Execute again:

configure --disable-all --enable -cli

The makefile file will be generated at this time, and we can use this file to compile

Just execute nmake directly.

At this time, only the command line PHP executable file is generated. If you want to set up a web, you need a CGI PHP executable file. You can add --enable-cgi after configure, as follows:

configure --disable- all --enable-cli --enable-cgi

Sometimes when we need to generate a module that can be used by apache, we also need to add apache parameters (here, use apache 2.2 as an example):

configure --disable-all --enable-cli --enable-cgi --enable-apache2-2handler

But please note that you need apache's sdk (h file and lib file) at this time. The official has provided the corresponding sdk package for 2008, which is included in In the deps file, you can download the deps-5.4-vc9-x86 file from the official website.

After downloading, just release it in the deps directory.

Post-note: This method is also suitable for vc6 to compile version 5.3 of php, but at this time you need to install 2003sdk first, and when errors occur, you need to manually change the file (ext/standard/broscap.c file has several errors);

In addition, the official dependency package of vc6 is no longer provided. For example, compiling the apache module cannot pass. At this time, I have to compile apache and extract the sdk.

2. xdebug compilation

Preparation:

Requires 2003sdk or 6.1 sdk. Assuming that 2003sdk is installed, enter the compilation environment in xp through the menu, and then use the above method to add the vs2008 environment.

To compile xdebug, you need to use the php sdk. This can be generated from the source code of php. Just execute it again in the above environment:

nmake install

By default, the php directory will be generated in the c drive, as follows Contains an sdk subdirectory. In this directory, we will see a phpize.bat file.

Release the xdebug source code to the previous x86 directory, assuming it is version 2.2.7, so the directory will be xdebug-2.2.7

Enter this directory and execute phpize, usually with the full path:

c: phpsdkphpize

This will generate 3 documents: configure.bat,configure.js,confi.nice.bat

Execute again

configure --with-xdebug

Generate makefile

Finally execute

nmake

This is it php_xdebug.dll was generated in the

release_ts directory

Later note: The 2.2.7 version of xdebug can be compiled successfully under PHP 5.4.37, but cannot be compiled successfully under 5.3.x. In addition, xdebug of 2.1.x cannot be compiled normally under PHP 5.4.37.

3.apache compilation

vc6, 2003sdk can compile version 2.2.22 apache, but the prerequisite is to download:

apr-1.5.1-win32-src.zip, arp-iconv-1.2.1-win32- src-r2.zip, apr-util-1.5.4-win32-src.zip

Unzip them and put them into the source code srclib directory, replace them if there are any.

Enter xp, 32-bit environment through the 2003 sdk menu item;

Enter the source code directory, execute:

nmake /f makefile.win

Then execute:

nmake /f makefilw.win INSTDIR=c :apache

You will get an error at this time, the awk executable file is missing, but you find that there is already something in the c:apache directory

Copy the include path and lib path to the corresponding path of deps in php,

depsincludeapache2_2 (Including h file)

depslibapache2_2 (Including lib file)

Now execute:

configure --disable-all --enable-apache2_2handler

nmake

The apache module can be generated.

                                                              

The above introduces how to compile the source code of php and xdebug on Windows, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn