phpinfo报告错误的pcre版本

时间:2012-02-17 05:12:17

标签: php apache command-line pcre

我花了一天时间试图找出一个奇怪的问题。我有一个WordPress网站遇到以下错误:

Warning: preg_replace() [function.preg-replace]: Compilation failed: unknown option bit(s) set at offset -1 in /path/to/public_html/wp-includes/shortcodes.php on line 257

wp-includes / shortcodes.php中的那一行如下:

$text = preg_replace("/[\x{00a0}\x{200b}]+/u", " ", $text);

我发现这篇文章似乎与我的问题相匹配:http://labs.sasslantis.ee/2011/05/errors-in-wordpress-after-php-upgrade/

本文描述了一种情况,其中apache和命令行中的phpinfo();输出与libpcre

有关

我通过在其中创建一个包含phpinfo();的测试文件来验证这是我的问题,并且还从shell中运行了以下内容:

php -r "phpinfo();"

脚本(apache?)版本返回PCRE Library Version 6.6 06-Feb-2006 命令行版本返回PCRE Library Version => 8.21 2011-12-12

我想知道该怎么做。我不是非常精通命令行使用,所以我转向你们都希望得到一些帮助。

文章提到“修复apache start-flags”。我不确定这意味着什么。

我还在其他地方发现了一条评论说:“好吧,事实证明问题是旧版本的libpcre在系统上闲逛并且误加载。一旦我更新到最新版本的libpcre,问题已解决。“我不完全确定如何在服务器上审查这些信息。

====编辑1 ====

我有更多信息:

/opt/pcre/bin/pcretest -C

返回

PCRE version 8.21 2011-12-12
Compiled with
UTF-8 support
Unicode properties support
No just-in-time compiler support
Newline sequence is LF
\R matches all Unicode newlines
Internal link size = 2
POSIX malloc threshold = 10
Default match limit = 10000000
Default recursion depth limit = 10000000
Match recursion uses stack

这并不奇怪,因为我们已经知道命令行会返回正确的版本。但是由于一些疯狂的未知原因,PHP在通过网络运行时,不会返回正确的pcre值。

====编辑2 ====

我在这篇文章中写道:http://www.bigboylemonade.com/pcre-version-problem-on-cpanel

在没有完整路径的情况下运行pcretest -C会返回:

PCRE version 6.6 06-Feb-2006
Compiled with
  UTF-8 support
  Unicode properties support
  Newline character is LF
  Internal link size = 2
  POSIX malloc threshold = 10
  Default match limit = 10000000
  Default recursion depth limit = 10000000
  Match recursion uses stack

我将会看到我可以采取哪些措施来执行这些最后的步骤,并且很快就会更新

2 个答案:

答案 0 :(得分:10)

好的,我终于得到了主持人关于他们如何解决问题的说明:

==================== Begin steps ==============================

当我开始使用此特定服务器时,这是可用的数据:

[root@host2] ~ >> pcretest -C PCRE
version 6.6 06-Feb-2006
Compiled with
UTF-8 support
Unicode properties support
Newline character is LF
Internal link size = 2
POSIX malloc threshold = 10
Default match limit = 10000000
Default recursion depth limit = 10000000
Match recursion uses stack

[root@host2] ~ >> /opt/pcre/bin/pcretest -C PCRE
version 8.21 2011-12-12
Compiled with
UTF-8 support Unicode properties support
No just-in-time compiler support
Newline sequence is LF
\R matches all Unicode newlines
Internal link size = 2
POSIX malloc threshold = 10
Default match limit = 10000000
Default recursion depth limit = 10000000
Match recursion uses stack

版本6.6也出现在任何phpinfo()网页和php -i中。     默认情况下,php版本> = 4.2,Apache编译标志'--with-pcre-regex'     是自动包含的,因此任何EA运行都将使用6.6。 cPanel的版本     提供。关键是要让操作系统了解我们的pcre库     希望Apache使用,所以第一步是:

[root@host2] etc >> echo "/opt/pcre/lib/" >> /etc/ld.so.conf

然后运行ldconfig - 现在我们有两个版本的PCRE的库     可供系统用户使用:

[root@host2] etc >> ldconfig -v | grep -i pcre
/opt/pcre/lib:
libpcre.so.0 -> libpcre.so.0.0.1
libpcrecpp.so.0 -> libpcrecpp.so.0.0.0
libpcreposix.so.0 -> libpcreposix.so.0.0.0
libpcre.so.0 -> libpcre.so.0.0.1
libpcre.so.0 -> libpcre.so.0.0.1
libpcrecpp.so.0 -> libpcrecpp.so.0.0.0
libpcreposix.so.0 -> libpcreposix.so.0.0.0
libpcrecpp.so.0 -> libpcrecpp.so.0.0.0
libpcreposix.so.0 -> libpcreposix.so.0.0.0
[root@host2] etc >>

耶!现在,告诉Apache使用那些而不是6.6,使用方便     rawopts文件并重建Apache:

[root@host2] etc >> echo "--with-pcre-regex=/opt/pcre" >>
/var/cpanel/easy/apache/rawopts/all_php5 [root@host2.brucesallan.com] etc >>
/scripts/easyapache --build

完成后,测试一下:

[root@host2] etc >> php -i | grep -i "pcre library" PCRE
Library Version => 8.21 2011-12-12 [root@host2.brucesallan.com] etc >>

[root@host2] ~ >> pcretest -C PCRE
PCRE version 8.21 2011-12-12
Compiled with
UTF-8 support
Unicode properties support
Newline character is LF
Internal link size = 2
POSIX malloc threshold = 10
Default match limit = 10000000
Default recursion depth limit = 10000000
Match recursion uses stack

[root@host2] ~ >> /opt/pcre/bin/pcretest -C PCRE
PCRE version 8.21 2011-12-12
Compiled with
UTF-8 support
Unicode properties support
No just-in-time compiler support
Newline sequence is LF
\R matches all Unicode newlines
Internal link size = 2
POSIX malloc threshold = 10
Default match limit = 10000000
Default recursion depth limit = 10000000
Match recursion uses stack

========================== End ============================

答案 1 :(得分:1)

在我们的例子中,apache没有使用--with-pcre参数编译 安装了Pcre和pcre-devel(从yum或apt存储库,无需编译),然后我们只需要找到pcre-config。
在我们的例子中是/ usr / bin / pcre-config,'bin'似乎是由apache编译器承担的,所以最终的./configure行必须包括:
- 与-PCRE = / USR