2012-02-17 33 views
9

我花了一天的時間試圖找出一個奇怪的問題。我有一臺運行到以下錯誤WordPress站點:phpinfo報告不正確pcre版本

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-包括/ shortcodes.php如下:

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

我發現這篇文章,似乎匹配相當好與我的問題:http://labs.sasslantis.ee/2011/05/errors-in-wordpress-after-php-upgrade/

本文介紹的情況,其中有在apache和上關於命令行來libpcre

phpinfo();不同的輸出

我證實,這是我的問題,通過創建與它phpinfo();測試文件,並且還跑到離殼以下:

php -r "phpinfo();" 

腳本(?阿帕奇)版本返回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通過web運行時,不會返回正確的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 

我要去看看我能做些什麼來執行這些最後步驟,並且很快就會更新

+0

PHP將使用PCRE安裝在您的系統上,並且Apache在此事上沒有發言權。查看你的庫目錄(/ var/lib?)以查看哪些版本在那裏。 – 2012-02-17 05:19:02

+0

有沒有辦法讓我能夠找到在哪裏看?我運行了'ldd/usr/bin/php | grep pcre',它指向我/ opt/pcre。如果這是接近的,那麼我只安裝一個? – 2012-02-17 05:30:34

+0

看看你的httpd.conf(/etc/httpd/conf.d/php.conf)文件來驗證哪個php模塊正在使用web服務器。 – jap1968 2012-02-17 07:23:44

回答

10

好吧,我終於從主持人那裏得到了關於他們如何修復問題的說明他的問題:

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

當我開始這個特定的服務器上,這是可用的數據:

[[email protected]] ~ >> 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 

[[email protected]] ~ >> /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 提供。這裏的關鍵是讓OS知道我們 想Apache來使用的PCRE庫,所以第一步是:

[[email protected]] etc >> echo "/opt/pcre/lib/" >> /etc/ld.so.conf 

然後運行ldconfig命令 - 現在我們有PCRE 的兩個版本的庫可供系統用戶使用:

[[email protected]] 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 
[[email protected]] etc >> 

Yay!現在,告訴Apache使用這些,而不是6.6的,使用方便的 rawopts文件和重建的Apache:

[[email protected]] etc >> echo "--with-pcre-regex=/opt/pcre" >> 
/var/cpanel/easy/apache/rawopts/all_php5 [[email protected]] etc >> 
/scripts/easyapache --build 

當它完成後,測試它:

[[email protected]] etc >> php -i | grep -i "pcre library" PCRE 
Library Version => 8.21 2011-12-12 [[email protected]] etc >> 

[[email protected]] ~ >> 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 

[[email protected]] ~ >> /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

太棒了!你保存了我們的培根。 – 2013-05-25 00:45:00

1

在我們的例子阿帕奇沒有使用--with-pcre參數編譯。
Pcre和pcre-devel被安裝(來自yum或apt倉庫,不需要編譯它),那麼我們只需要找到pcre-config。
在我們的例子中,它是/ usr/bin/pcre-config,'bin'好像是由apache編譯器假定的,所以最後的./configure行必須包含:
--with-pcre =/usr