问题描述
我正在处理的代码在 Windows XP 和 Mac OS X 上完美运行.在 CentOS(以及 Fedora 和 Ubuntu)上测试时,它无法正常工作.搜索网络使我得出结论,它是导致问题的 iconv
的 glibc
版本.所以现在我需要 iconv
的 libiconv
版本才能让 Zend Lucene 正常工作.
The code I'm working on runs perfectly on Windows XP and on Mac OS X. When testing it on CentOS (and on Fedora and Ubuntu), it's not working properly. Searching the nets led me to the conclusion that it's the glibc
version of the iconv
that's causing the problem. So now I need the libiconv
version of iconv
for Zend Lucene to work properly.
我已经下载了 libiconv 并使用 --prefix=/usr/local
、make
和 make install
对其进行了配置,没有任何错误.好像安装成功了,因为执行/usr/local/bin/iconv --version
说版本是libiconv
.虽然一个简单的 iconv --version
仍然给出了 glibc
版本.
I already downloaded libiconv and configured it with --prefix=/usr/local
, make
, then make install
without any errors. It seems that it was successfully installed because executing /usr/local/bin/iconv --version
says the version is the libiconv
. Although a simple iconv --version
still gives the glibc
version.
然后我使用 --with-iconv=/usr/local
从源代码重新编译 PHP.但是,phpinfo()
显示正在使用的 iconv
是 glibc
版本.我也已经使用 --with-iconv-dir
或使用 /usr/local/bin/php
尝试了其他几种编译.
Then I recompiled PHP from source using --with-iconv=/usr/local
. But still, the phpinfo()
is showing the iconv
being used is the glibc
version. I've also already tried several other compiles using --with-iconv-dir
or using /usr/local/bin/php
.
当然,我在重新编译 PHP 后重新启动了 web 服务器.
Of course, I restarted the web server after recompiling PHP.
我的 /etc/httpd/conf/httpd.conf
中有以下行:
LoadModule /usr/lib/httpd/modules/libphp5.so
和libphp5.so
实际上在/usr/lib/httpd/modules
中.
phpinfo()
显示 PHP 5.3.3.我也 yum 删除了预安装的 PHP 5.1.* 只是为了确保.但是iconv还是用的glibc版本.
phpinfo()
shows PHP 5.3.3. I also yum removed the pre-installed PHP 5.1.* just to make sure. But the iconv is still using the glibc version.
ldd/usr/lib/httpd/modules/libphp5.so
给出
linux-gate.so.1 => (0x003b1000)
/usr/local/lib/preloadable_libiconv.so (0x00110000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x001ed000)
librt.so.1 => /lib/librt.so.1 (0x0021f000)
libmysqlclient.so.15 => /usr/lib/mysql/libmysqlclient.so.15 (0x003b2000)
libldap-2.3.so.0 => /usr/lib/libldap-2.3.so.0 (0x0026e000)
liblber-2.3.so.0 => /usr/lib/liblber-2.3.so.0 (0x00370000)
libiconv.so.2 => /usr/local/lib/libiconv.so.2 (0x00516000)
libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x002a8000)
libpng12.so.0 => /usr/lib/libpng12.so.0 (0x00228000)
libz.so.1 => /usr/lib/libz.so.1 (0x00328000)
libcurl.so.3 => /usr/lib/libcurl.so.3 (0x00f23000)
libm.so.6 => /lib/libm.so.6 (0x0033b000)
libdl.so.2 => /lib/libdl.so.2 (0x00364000)
libnsl.so.1 => /lib/libnsl.so.1 (0x0037e000)
libxml2.so.2 => /usr/lib/libxml2.so.2 (0x00f5f000)
libssl.so.6 => /lib/libssl.so.6 (0x0862c000)
libcrypto.so.6 => /lib/libcrypto.so.6 (0x04145000)
libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0x08e2d000)
libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0x0611a000)
libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0x005f4000)
libcom_err.so.2 => /lib/libcom_err.so.2 (0x0024e000)
libidn.so.11 => /usr/lib/libidn.so.11 (0x071f5000)
libc.so.6 => /lib/libc.so.6 (0x08aa6000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00397000)
/lib/ld-linux.so.2 (0x00251000)
libresolv.so.2 => /lib/libresolv.so.2 (0x0748a000)
libsasl2.so.2 => /usr/lib/libsasl2.so.2 (0x07ddf000)
libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0x062b7000)
libkeyutils.so.1 => /lib/libkeyutils.so.1 (0x00369000)
libselinux.so.1 => /lib/libselinux.so.1 (0x0913b000)
libsepol.so.1 => /lib/libsepol.so.1 (0x07eb4000)
这是来自:NullPointer.ph
推荐答案
我刚刚通过手动重新编译 php iconv 扩展,将我的 php-5.3.3 从 glibc 的 iconv 更改为 GNU libiconv.请按照以下步骤操作:
I just have changed my php-5.3.3 from glibc's iconv to GNU libiconv through the manual recompiling of the php iconv extension. Follow these steps:
- 下载php-5.3.3 源代码包
- 解压并进入
php-5.3.3/ext/iconv
子目录 - 执行
phpize
命令(如果你没有这个命令就安装php-devel
包) (*) 编辑配置文件 (
vim configure
):在 4664 行添加iconv_impl_name=""
(您系统配置上的确切行号可能不同):
- download php-5.3.3 source code package
- extract it and go into
php-5.3.3/ext/iconv
subdirectory - execute
phpize
command (if you have no such command then installphp-devel
package) (*) edit configure file (
vim configure
): addiconv_impl_name=""
at 4664 line (exact line number on your system configuration may be different):
...
iconv_impl_name=""
if test -z "$iconv_impl_name"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if using GNU libiconv" >&5<
...
./configure --with-iconv=/usr/local|grep iconv
:
checking if using GNU libiconv... yes
制作
现在我运行 php -i|grep "iconv impl"
并得到:
And now I run php -i|grep "iconv impl"
and got:
iconv implementation => libiconv
* 这个技巧强制配置选择 GNU libiconv 而不是 glibc 的 iconv.默认情况下,它在第一步检查 glibc 的 iconv 并且根本不检查 GNU libiconv.
* This trick forces configure to select the GNU libiconv instead of glibc's iconv. By default it checks for glibc's iconv at first step and does not check for GNU libiconv at all.
这篇关于如何强制 PHP 使用 iconv 的 libiconv 版本而不是 CentOS 安装的 glibc 版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!