我花了一天时间试图解决一个奇怪的问题。我的 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/
这篇文章描述了一种情况,在这种情况下,phpinfo();
在 apache 和命令行中关于 libpcre
我通过在其中创建一个包含 phpinfo();
的测试文件并从 shell 运行以下命令来验证这是我的问题:
php -r "phpinfo();"
脚本(apache?)版本返回 PCRE Library Version 6.6 06-Feb-2006
命令行版本返回 PCRE Library Version => 8.21 2011-12-12
我不知道该怎么办。我不太精通命令行用法,所以我向大家求助,希望能得到一些帮助。
文章提到“修复 apache 启动标志”。我不确定那是什么意思。
我还在其他地方发现了一条评论:“好的,事实证明问题是旧版本的 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
我将看看我能做些什么来执行最后的步骤,并将很快更新
最佳答案
好的伙计们,我终于从房东那里收到了关于他们如何解决问题的说明:
==================== 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 ============================
关于phpinfo 报告不正确的 pcre 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9323228/