x64系统下PHP 5.2.6静态编译加入GD导致iconv无法使用
十月 15th, 2008 Posted in PHP < by Johnny Woo >
环境如下
CentOS 5.2 x64以及x86
php-5.2.6
gd-2.0.35
freetype-2.3.7
jpegsrc.v6b
libpng-1.2.31
在x64下全部加入编译后
<?php
./configure --prefix=/root/php --with-config-file-path=/root/php \
--enable-fastcgi --enable-force-cgi-redirect \
--with-libxml-dir=/usr/local/webserver/libxml \
--with-gd=/root/gd \
--with-jpeg-dir=/usr/local/webserver/jpeg \
--with-png-dir=/usr/local/webserver/libpng \
--enable-gd-native-ttf \
--with-freetype-dir=/usr/local/webserver/freetype \
--enable-gd-jis-conv \
--with-curlwrappers \
--with-zlib-dir \
--with-zlib \
--with-pear \
--with-openssl \
--without-pdo-sqlite \
--without-sqlite \
--disable-debug \
--disable-rpath \
--with-iconv \
--enable-bcmath \
--enable-pcntl \
--enable-mbstring \
--enable-exif \
--enable-zip \
--enable-ftp
./configure --prefix=/root/php --with-config-file-path=/root/php \
--enable-fastcgi --enable-force-cgi-redirect \
--with-libxml-dir=/usr/local/webserver/libxml \
--with-gd=/root/gd \
--with-jpeg-dir=/usr/local/webserver/jpeg \
--with-png-dir=/usr/local/webserver/libpng \
--enable-gd-native-ttf \
--with-freetype-dir=/usr/local/webserver/freetype \
--enable-gd-jis-conv \
--with-curlwrappers \
--with-zlib-dir \
--with-zlib \
--with-pear \
--with-openssl \
--without-pdo-sqlite \
--without-sqlite \
--disable-debug \
--disable-rpath \
--with-iconv \
--enable-bcmath \
--enable-pcntl \
--enable-mbstring \
--enable-exif \
--enable-zip \
--enable-ftp
发现使用iconv函数
数据输出为空
代码如下
<?php
$str="你好";
print $str;
print "\n";
echo iconv( "GBK", "UTF-8", $str );
?>
$str="你好";
print $str;
print "\n";
echo iconv( "GBK", "UTF-8", $str );
?>
接着我将其他模块去掉.只保留iconv
php执行正常
接着加入了gd库.发现又无法正常输出
将gd库作为模块加入
则iconv能够正常输出
接下来我怀疑是x64特有的内存存取的问题
而这期间,martian也说他的台式机上运行正常,即便加上GD库静态编译也能正常输出iconv
然后我就在台式机上安装干净的虚拟机
从头进行编译
发现x86上使用相同配置方法进行编译的php静态加入gd以及iconv
能够正常的输出iconv
说明确实是在x64位下才会发生的问题
如果是64bit下的linux.使用php加入这两个模块.要记得吧gd作为动态模块加载
才不会导致iconv故障