search
HomeBackend DevelopmentPHP Tutorialwindows 上 怎样编译 php 跟 xdebug的 源代码

windows 上 怎样编译 php 和 xdebug的 源代码

网上有很多的php源代码编译介绍,但是几乎没有xdebug 的源码编译的介绍,我这里结合自己的实际操作来谈一下,其中也会涉及到apache源代码的编译。

1. php编译

我们以vs2008来作为编译工具;其他还需要php的编译套件,这个可在php官方网下载http://windows.php.net/downloads/php-sdk/,下载这个吧:

php-sdk-binary-tools-20110915.zip

假设把它释放到e:\php-sdk目录下

从开始菜单进入command-line模式:

先把vs2008的环境配置好,在命名模式下进入2008的安转路径,假设在c:\program files\micorosft visual studio v9.0; 则再次进入该目录下的vc子目录:

cd vc

c:\program files\micorosft visual studio v9.0\vc 此时执行vcvarsall.bat

c:\program files\micorosft visual studio v9.0\vc\vcvarsall.bat

这样2008的执行环境就建立好了。

下一步就是进入到php-sdk目录下,

e:\php-sdk

执行

bin\phpsdk_setvars.bat

接下来执行:

bin\phpsdk_buildtree.bat phpdev

这下就会在当前目录创建一子目录phpdev,我们把下载回来的php源代码放入到其子目录vc9/x86下面,以5.4.73为例子,这样就会目录就会是这样:

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

进入到php-5.4.37目录,执行

buildconf

这时会产生configure.bat和configure.js 文件

再次执行:

configure --disable-all --enable-cli

这时候就会产生makefile 文件,我们就可以用这个文件进行编译

直接执行nmake就可以了。


这时候只产生命令行的php执行档,如果想要架设web,那就需要一个cgi的php执行档,可在configure 后面加上 --enable-cgi,如下:

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

有时候我们要需要产生apache能用的module ,就还要加上apache的参数(这里以apache 2.2为例子):

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

但请注意,这时候需要apache 的sdk(h文件和lib文件),官方已提供了2008的对应sdk包,它包含在deps文件里面,可在官方下载deps-5.4-vc9-x86文件。

下载后把它释放在deps目录下就可以了。


 后注:这个方法也适合vc6来编译5.3版的php,只是这时候要先安装2003sdk, 出错时要手动去更改一下文件(ext/standard/broscap.c文件有几处错误);

           另外官方不再提供vc6的依赖包,比如编译apache 的module就过不了,这时只有自己在去编译apache,把sdk提取出来。

2. xdebug 编译

前期准备:

需要2003sdk或 6.1 sdk,假设安装的2003sdk,现通过菜单进入在xp的编译环境,再用上面的方法把vs2008环境加进来。


要编译xdebug,需要用到php的sdk, 这个可以从php 的源代码中产生,只要在上面的环境中再次执行:

nmake install

默认情况下会在c盘产生php目录,下面包含一个sdk子目录,在这个目录中,我们将看到有一个phpize.bat文件。

把xdebug源代码释放到前面的x86目录下,假设为2.2.7版,这样目录就为xdebug-2.2.7

进入到这个目录,执行phpize,一般带全路径执行:

c:\php\sdk\phpize

这样会产生3个文档:configure.bat,configure.js,confi.nice.bat

再次执行

configure --with-xdebug

产生makefile

最后执行

nmake

这样就在

release_ts目录下产生了php_xdebug.dll


后注:2.2.7版的xdebug之能在php 5.4.37下编译成功,但不能在5.3.x 下编译成功。另外2.1.x的xdebug也不能在php 5.4.37 下正常编译。


3.apache 编译

vc6,2003sdk 可以编译2.2.22版apache,但前提条件是要下载:

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

解压它们并把它们放入源代码srclib目录下,如果有的就替换掉。

通过2003 sdk 的菜单项进入到xp,32位环境;

进入到源代码目录,执行 :

nmake /f makefile.win

而后执行 :

nmake /f makefilw.win INSTDIR=c:\apache

这时会抱错,缺少awk执行文件,但是你发现c:\apache目录下已经有东西了

把里面的include 路径和lib路径拷贝到php 的deps 相对应路径下,

deps\include\apache2_2    (包含h文件)

deps\lib\apache2_2           (包含lib文件)

这时执行:

configure --disable-all --enable-apache2_2handler

nmake

就可以产生apache 的module了。

         




 






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
PHP Performance Tuning for High Traffic WebsitesPHP Performance Tuning for High Traffic WebsitesMay 14, 2025 am 12:13 AM

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

Dependency Injection in PHP: Code Examples for BeginnersDependency Injection in PHP: Code Examples for BeginnersMay 14, 2025 am 12:08 AM

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

PHP Performance: is it possible to optimize the application?PHP Performance: is it possible to optimize the application?May 14, 2025 am 12:04 AM

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

PHP Performance Optimization: The Ultimate GuidePHP Performance Optimization: The Ultimate GuideMay 14, 2025 am 12:02 AM

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

PHP Dependency Injection Container: A Quick StartPHP Dependency Injection Container: A Quick StartMay 13, 2025 am 12:11 AM

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Dependency Injection vs. Service Locator in PHPDependency Injection vs. Service Locator in PHPMay 13, 2025 am 12:10 AM

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHP performance optimization strategies.PHP performance optimization strategies.May 13, 2025 am 12:06 AM

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHP Email Validation: Ensuring Emails Are Sent CorrectlyPHP Email Validation: Ensuring Emails Are Sent CorrectlyMay 13, 2025 am 12:06 AM

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools