Home Backend Development PHP Tutorial windows 上 怎样编译 php 跟 xdebug的 源代码

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

Jun 13, 2016 pm 12:16 PM
apache nbsp 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 of this Website
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

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 Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP's Purpose: Building Dynamic Websites PHP's Purpose: Building Dynamic Websites Apr 15, 2025 am 12:18 AM

PHP is used to build dynamic websites, and its core functions include: 1. Generate dynamic content and generate web pages in real time by connecting with the database; 2. Process user interaction and form submissions, verify inputs and respond to operations; 3. Manage sessions and user authentication to provide a personalized experience; 4. Optimize performance and follow best practices to improve website efficiency and security.

PHP in Action: Real-World Examples and Applications PHP in Action: Real-World Examples and Applications Apr 14, 2025 am 12:19 AM

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP and Python: Different Paradigms Explained PHP and Python: Different Paradigms Explained Apr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: Code Examples and Comparison PHP and Python: Code Examples and Comparison Apr 15, 2025 am 12:07 AM

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

PHP: Handling Databases and Server-Side Logic PHP: Handling Databases and Server-Side Logic Apr 15, 2025 am 12:15 AM

PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

Choosing Between PHP and Python: A Guide Choosing Between PHP and Python: A Guide Apr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

Why Use PHP? Advantages and Benefits Explained Why Use PHP? Advantages and Benefits Explained Apr 16, 2025 am 12:16 AM

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.

PHP and Python: A Deep Dive into Their History PHP and Python: A Deep Dive into Their History Apr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

See all articles