Books

Feed

Categories

Ads

Recent Posts

Ads

Security Advisories

RSS FreeBSD Advisories

RSS NetBSD Advisories

Fixing PCRE_UTF8 Errors in FreeBSD


I have recently encountered this error:
PHP Warning: preg_match(): Compilation failed: this version of PCRE is not compiled with PCRE_UTF8 support at offset 0

And despite some of the suggested solutions I have found in various Drupal and MediaWiki forums, all of them related to older versions of ports.
The version of pcre I have installed is 7.8. as seen here:

PCRE version 7.8 2008-09-05
Compiled with
UTF-8 support
Unicode properties 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

But the curious thing is phpinfo(), told a different story.

 
Why was phpinfo() telling me the version of pcre was 5.0.13?
I checked various things like which libraries php was linked to, and sure enough it was in fact the libpcre that it should have been. After countless iterations of “let me tweak this Makefile and see if it makes a difference” and countless rebuilds of pcre and php, it occurred me, what about Apache? Now I’m not really sure why I this occurred to me, or why it did not occur to me earlier, perhaps it was a result of having felt I had already exhausted the rest of my options.

So I took a look at the Apache build config:

# cd /usr/ports/www/apache22
# make config


 
Apparently the pcre Apache is using is a bundled one, so I decided to change this to use devel/pcre, where I know UTF-8 support is enabled.

 
and proceeded to rebuild and reinstall the apache22 port.
After restarting apache, my first test was to inspect what phpinfo() was reporting.

 
Now phpinfo is agreeing with what I originally expected it to, the pcre port that is installed. I proceeded to test my php code with great success and have not seen the error since.

I encountered this on FreeBSD 7.0 , Apache 2.2.9, PHP 5.2.7, and pcre 7.8. But given the large number of seemingly unresolved threads I’ve encountered through google I expect that there are similar situations in other operating systems and software versions as well.

Comments

Comment from Jake
Time: December 8, 2008, 1:36 am

Great catch! I was really scratching my head over this one & repeatedly rebuilding pcre, php5 & apache with different make options. I think this was brought on by devel/php5-pcre being integrated into the php5 base (http://supernews.freshports.org/devel/php5-pcre/), since this issue showed up the same day that happened.

Comment from Mark
Time: March 8, 2009, 2:56 am

it seems like this is now fixed in the apache22 port. I encountered the same problem and simply upgraded from 2.2.9 to 2.2.11 and it now uses the system PCRE lib. A “make config” does not show any pcre options anymore.

Comment from Jurgen
Time: March 24, 2009, 8:14 pm

Mark, I have tried this and it is still failing for me. :(

I have rebuilding www/apache22, devel/pcre and devel/php5-pcre

any ideas on how to get this working again?

Pingback from notes » Blog Archive » ?????? PCRE_UTF8 ? FreeBSD
Time: April 10, 2009, 4:32 am

[...] ? ???????? ????????? MediaWiki ??????? ?????????? ??????? ????? ??? ?????????: “Warning: preg_match(): Compilation failed: this version of PCRE is not compiled with PCRE_UTF8 support at offset 0“. ????????, ??????????, ??? ??????? Apache – ?? ??????????? ?????-?? ???? pcre ?????? ????, ??? ??? ? ??????. ????? ???? ??????????? ??? ???? ?????. ? ???? ?? ?????????? ??????, ? ?????? ??????? Apache (??? ????? ????????? ???????) ? ??? ??????????. ?????????????? ?????????: Fixing PCRE_UTF8 Errors in FreeBSD [...]

Comment from lifeforms
Time: July 19, 2009, 3:46 pm

I couldn’t believe you, but it worked!

Rebuilding Apache caused a jump in the PCRE version reported by phpinfo() from “5.0 13-Sep-2004″ to the pcre port’s version.

So apparently PHP is using the pcre bundled by apache.

I might add that nowadays, the port maintainer has fixed this issue. Apache 2.2.11 no longer has the config option to use its own PCRE, but always uses the system version. :)

Comment from Onur
Time: October 20, 2009, 9:11 am

Thank four your information, it saved the day.

Comment from jack
Time: December 15, 2009, 8:32 am

just rebuild php with

/usr/ports/lang/php5/Makefile
CONFIGURE_ARGS:
–with-pcre-regex

Pingback from ?????? PCRE_UTF8 ? FreeBSD « IT ???????
Time: March 19, 2010, 1:17 am

[...] ???????) ? ??? ??????????. ?????????????? ?????????: Fixing PCRE_UTF8 Errors in FreeBSD ???????? [...]

Write a comment