Heim  >  Artikel  >  php教程  >  windows下编译php扩展 eAccelerator

windows下编译php扩展 eAccelerator

WBOY
WBOYOriginal
2016-06-06 19:53:53990Durchsuche

eAccelerator是一个开源PHP加速器,用于优化程序,编码器和动态内容缓存。它通过在编译状态下对PHP脚本进行缓存以提高他们的性能,所以那些系统开销在编译时几乎可以被消除。它还能够对脚本进行优化以便加速它们的执行速度。利用eAccelerator可以减少服务器

eAccelerator是一个开源PHP加速器,用于优化程序,编码器和动态内容缓存。它通过在编译状态下对PHP脚本进行缓存以提高他们的性能,所以那些系统开销在编译时几乎可以被消除。它还能够对脚本进行优化以便加速它们的执行速度。利用eAccelerator可以减少服务器的负载并提高PHP代码的执行效率。


一、前期准备

1、下载php原代码和二进制包

地址:http://windows.php.net/download/

2、下载eaccelerator(选择zip包)

地址:http://eaccelerator.net/

3、php配置文件config.w32.h

地址:http://download.csdn.net/detail/cwqcwk1/5675195

 

Ps:

1、 下载二进制包及配置文件,主要是为了省去编译php的过程

2、 Php在win下分vc9、vc6等版本,下载前要选好,编译后的扩展只能用于对应版本的php

3、 如果选vc6,vc11,则要修改config.w32.h中对应的vc信息

 

二、解压过程(本例选vc9)

1、 直接解压php-5.3.26-src.zip,eaccelerator.zip到d:\

2、 复制config.w32.h到d:\php-5.3.26-src\main目录

3、 解压php-5.3.26-Win32-VC9-x86.zip需要解压到d:\php目录

4、 把d:\php\dev\php5ts.lib复制到eaccelerator文件夹

5、 把eaccelerator文件夹剪切到d:\php-5.3.26-src\ext

 

三、编译过程(错误可能与eaccelerator版本有关)

1、 打开eaccelerator项目..\win32\eAccelerator.sln,设置为Win32 Release。

2、 配置项目属性:链接库-常规,附加库目录补充“.\..”;

3、 开始编译项目,可能发生以下错误:

../../../main\streams/php_stream_transport.h(85): error C2143: syntax error : missing ')' before '*'

../../../main\streams/php_stream_transport.h(85): error C2081: 'socklen_t' : name in formal parameter list illegal

解决:这是由于找不到宏报的错误。打开这个文件,添加typedef int socklen_t;

4、 继续编译,可能发生以下错误:

\ext\eaccelerator\ea_store.c(205): error C2143: syntax error : missing ';' before 'type'

\ext\eaccelerator\ea_store.c(207): error C2065: 'opline' : undeclared identifier

解决:这是由于项目该处没用规范的C写法,把“zend_op *opline, *end;”移到“ADDSIZE(size, from->last * sizeof(zend_op));”上面,也就是if 结构中的首部。

5、 继续编译,应该没有其他错误了,完成后在Release目录找到eAccelerator_ts.dll

 

四、结束语

1、 写这篇文章,不仅说明如何在windows下编译eAccelerator,同时也说明了在windows下可以直接编写php扩展,无须借助cygwin等等

2、 Php版本控制不是很理想,估计也很难避免的。4.0和5.0或者5.3都存在很大差别,而且同一版本中还有编译器的差别,线程安全的差别,所以开发当中也要注意这个问题。


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:php正则学习Nächster Artikel:PHP 基础教程之字符串操作