|
This story is for apache 2.2 on a centos 5 (redhat) system. It probably applies to many other unix flavours. The error message discussed here appeared in a joomla php file that was processed in php 5.x.
In my apache httpd server 2.2 error log file I got the following warning message:
warning: preg_replace() [function.preg-replace]: Compilation failed: this version of PCRE is not compiled with PCRE_UTF8 support
A similar log message is:
warning: preg_match() [function.preg-match]: Compilation failed: this version of PCRE is not compiled with PCRE_UTF8 support
It turned out that php uses a system component called PCRE for regular expression search. This component needs to be compiled with UTF-8 support. I checked this with the following command line:
bash$ pcretest -C
PCRE version 6.6 06-Feb-2006
Compiled with
UTF-8 support
No 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
So my installed version of PCRE has UTF-8 support and yet I am still seeing the error message. After much searching it turned that php uses PCRE that is bundled with Apache 2.2. And the version of PCRE php uses was version 5, pretty old. I checked it with the php function phpinfo(). Apache can use the system installation of PCRE instead of the bundled version of PCRE. All you have to do is recompiling Apache using option --with-pcre=PATH in the configure command for this recompile. The path is the location of your PCRE installation, which is usually /usr.
Unfortunately it was not possible to recompile apache. Apache's configure script produced an error message saying that it was missing a file pcre-config. This script did not seem to install when installing PCRE with yum. It might be in yum package pcre-devel. Copying the pcre-config script that was bundled with apache to directory /usr/bin might have worked as well.
Instead I downloaded and compiled the PCRE package from source, with configure options to enable UTF-8 of course. In the end that was not that difficult. So I compiled and installed PCRE and then did the same for the apache webserver. After restarting the webserver I saw that the warnings did not appear any more in the error log file. From the php function phpinfo it turned out that php was indeed using the latest version of PCRE.
Update on November 24, 2010: the php website now reports that the new version of php, version 5.3.3, now uses PCRE version 8.02 which should solve this problem.
|