How to compile the source code for PHP and Xdebug on Windows

Source: Internet
Author: User
Tags php compiler vc9

There are a lot of PHP source code to compile the introduction, but almost no xdebug of the source of the introduction of the compilation, I am here to combine their actual operation to talk about, which will also involve the Apache source code compilation.

1. PHP compilation

We use vs2008 as a compile tool, and other PHP compiler kits, which can be downloaded from the official PHP web http://windows.php.net/downloads/php-sdk/, download this bar:

Php-sdk-binary-tools-20110915.zip

Let's say we release it to the E:\PHP-SDK directory.

Enter command-line mode from the Start menu:

First of all, the VS2008 environment is configured, in the naming mode into the 2008 of the path, assuming the C:\Program files\micorosft Visual Studio v9.0; Then enter the VC subdirectory in the directory again:

CD VC

C:\Program files\micorosft Visual Studio V9.0\VC execution Vcvarsall.bat at this time

C:\Program files\micorosft Visual Studio V9.0\vc\vcvarsall.bat

So 2008 of the execution environment is set up.

The next step is to enter into the PHP-SDK directory,

E:\php-sdk

Perform

Bin\phpsdk_setvars.bat

Next Execute:

Bin\phpsdk_buildtree.bat Phpdev

This will create a subdirectory in the current directory Phpdev, we put the downloaded PHP source code into its subdirectory vc9/x86 below, to 5.4.73 as an example, so the directory will be like this:

e:\php-sdk\phpdev\vc9/x86/php-5.4.37

Go to the php-5.4.37 directory and execute

Buildconf

Configure.bat and configure.js files are generated

Execute again:

Configure--disable-all--ENABLE-CLI

The makefile file is generated and we can compile it with this file.

Execute NMAKE directly.


This time only generates the command line PHP execution file, if you want to set up the web, it will need a CGI PHP executable file, you can add--enable-cgi after configure, as follows:

Configure--disable-all--enable-cli--enable-cgi

Sometimes we need to produce a module that Apache can use, and then add the Apache parameters (here is the Apache 2.2 example):

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

However, please note that this time requires the Apache SDK (H file and Lib file), the official has provided 2008 of the corresponding SDK package, which is included in the Deps file, can be downloaded in the official deps-5.4-vc9-x86 file.

Download it and release it to the Deps directory.


After note: This method is also suitable for VC6 to compile version 5.3 php, just this time to install 2003SDK, error when you have to manually change the file (ext/standard/broscap.c file has several errors);

In addition, the official no longer provide VC6 dependency package, such as compiling Apache module will not live, then only to compile Apache, the SDK extracted.

2. Xdebug Compilation

Pre-Preparation:

Need 2003sdk or 6.1 SDK, assuming the 2003sdk installed, now through the menu into the XP compilation environment, and then use the method above to add the VS2008 environment.


To compile the xdebug, you need to use the PHP SDK, which can be generated from the source code of PHP, as long as the above environment to execute again:

NMAKE Install

The PHP directory is generated by default on the C drive, with an SDK subdirectory below, where we will see a phpize.bat file.

Release the Xdebug source code to the previous x86 directory, assuming the version 2.2.7, so that the directory is xdebug-2.2.7

Go to this directory, execute phpize, usually with full path execution:

C:\php\sdk\phpize

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

Execute again

Configure--with-xdebug

Produce makefile

Final execution

Nmake

This is where

The Php_xdebug.dll is produced under the Release_ts directory.


Post Note: The 2.2.7 version of Xdebug can be compiled successfully under PHP 5.4.37, but cannot be successfully compiled under 5.3.x. In addition, 2.1.x Xdebug can not be compiled under PHP 5.4.37 properly.


3.apache compilation

VC6,2003SDK can compile 2.2. version 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, if any, replace them.

Access to the XP,32 environment via the 2003 SDK menu item;

Go to the source code directory and execute:

nmake/f Makefile.win

Then execute:

nmake/f Makefilw.win Instdir=c:\apache

This will be a mistake, the lack of awk to execute the file, but you found that the C:\apache directory is already something

Copy the include path and Lib path inside the PHP deps relative path,

Deps\include\apache2_2 (contains h file)

Deps\lib\apache2_2 (contains lib file)

This is done:

Configure--disable-all--enable-apache2_2handler

Nmake

You can produce Apache's module.










How to compile the source code for PHP and Xdebug on Windows

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.