phpinfo 报告错误的 pcre 版本 [英] phpinfo is reporting incorrect pcre version

查看:35
本文介绍了phpinfo 报告错误的 pcre 版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've spent the day trying to figure out a strange problem. I have a WordPress site that is running into the following error:

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 中的那一行如下:

That line in wp-includes/shortcodes.php is as follows:

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

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

I found this article that seemed to match up fairly well with my problem: http://labs.sasslantis.ee/2011/05/errors-in-wordpress-after-php-upgrade/

该文章描述了一种情况,其中 phpinfo(); 在 apache 和命令行中 libpcre

The article describes a situation in which there is different output of phpinfo(); in apache and on commandline with regard to libpcre

我通过在其中创建一个带有 phpinfo(); 的测试文件并从 shell 运行以下命令来验证这是我的问题:

I verified that this is my issue by creating a test file with phpinfo(); in it and also ran the following from the shell:

php -r "phpinfo();"

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

The script (apache?) version returns PCRE Library Version 6.6 06-Feb-2006 The commandline version returns PCRE Library Version => 8.21 2011-12-12

我不知道该怎么办.我不太精通命令行的使用,所以我向你们求助,希望能得到一些帮助.

I'm left wondering what to do. I'm not super well versed in command line usage, so I'm turning to you all hoping for some help.

文章提到了修复 apache 启动标志".我不确定这意味着什么.

The article mentions "fixing apache start-flags". I'm not sure what that means.

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

I've also found a comment somewhere else saying: "OK, it turned out that the problem was an older version of libpcre hanging around on the system and getting loaded by mistake. Once I updated to the latest version of libpcre, problem fixed." I'm not entirely sure how to vet this information on the server.

==== 编辑 1 ====

==== Edit 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 值.

This is not entirely surprising because we already know that the command line returns the correct version. But for some crazy unknown reason PHP, when run via the web, doesn't return the proper pcre values.

==== 编辑 2 ====

==== Edit 2 ====

我收到了这篇文章:http://www.bigboylemonade.com/pcre-version-problem-on-cpanel

运行 pcretest -C 而不返回完整路径:

Running pcretest -C without the full path returns:

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

我将看看我能做些什么来执行最后的步骤,并将很快更新

I'm going to see what I can do about performing those last steps and will update shortly

推荐答案

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

Ok guys, I finally got the notes from my host about how they fixed the problem:

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

当我在这个特定的服务器上开始时,这是可用的数据:

when I started on this particular server, this was the data available:

[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,所以第一步是:

Version 6.6 was also showing up in any phpinfo() webpage and also in php -i. By default in php versions >= 4.2, the Apache compile flag '--with-pcre-regex' is automagically included, so any EA run will use the 6.6. version that cPanel provides. The key to this was letting the OS know about the pcre libraries we want Apache to use, so the first step was to:

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

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

Then running ldconfig -- now we have the libraries for both versions of PCRE available for the system users:

[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:

Yay! Now, to tell Apache to use those instead of the 6.6 ones, use the handy rawopts file and rebuild 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 ============================

这篇关于phpinfo 报告错误的 pcre 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆