标题:PHP Extension: Unable To Initialize Module 出处:Felix021 时间:Mon, 30 Aug 2010 14:30:44 +0000 作者:felix021 地址:https://www.felix021.com/blog/read.php?1926 内容: 引用 Warning: Unable to initialize module Module compiled with module API=20050922, debug=0, thread-safety=1 PHP compiled with module API=20020429, debug=0, thread-safety=1 These options need to match 由于在编译的时候API版本信息(API version)会被嵌入到.so文件中,而PHP在载入扩展时会检查扩展中的API Version与当前版本的API Version是否相同。如果不相同,则拒绝载入。 如果出现类似的WARNING,可能的情况有2: 1. 这个 .so 扩展文件是你自己从php源码编译的 2. 这个 .so 扩展文件是从其他地方下载下来的 但是比较囧的是,比如,在Ubuntu上面,安装了php5,php5-dev,默认的 phpize + configure + make 生成的扩展的API Version是与ubuntu源中的php版本相同;如果需要编译另一个版本的PHP扩展(比如godaddy上的5.2.8),就不能这么直接了,解决办法是: 1. 到php.net去下载对应版本的php代码,比如php5.2.8.tar.bz2,解压到 xxx/php 2. 编译php $ cd xxx/php && ./configure && make 3. 使该版本的phpize、php-config可用 $ cd xxx/php/scripts; chmod +x phpize php-config 4. 编译扩展 $ cd 扩展源代码路径 $ xxx/php/scripts/phpize $ ./configure --with-php-config=xxx/php/scripts/php-config #注意这个with-php-config参数 $ make 编译好后的.so文件就在 modules 目录下面了 Generated by Bo-blog 2.1.0