PCRE version problem on cPanel

I upgraded one of our cPanel machines running FreeBSD 8.1 last night with success but when I upgraded to Apache 2.2.17 and PHP 5.3.4 a lot of our sites started to see the following error message:

Warning: preg_replace() [function.preg-replace]: Compilation failed: unknown option bit(s) set at offset 0…..

After hunting around the internet and cPanel forums it pointed us to the problem that the PCRE version that was being used to be build PHP was referencing /opt/pcre rather than the new location of the module in /usr/local. The alternatives were to downgrade to PHP 5.3.3 or manually upgrade the PCRE module. As we could not downgrade due to a compile issue with FreeBSD and PHP 5.3.3 our only option was to try to force PHP to compile PCRE with the correct path.

We found the problem by running the following test

# /opt/pcre/bin/pcretest -C

PCRE version 8.02 2010-03-19
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 if we ran it from the command line and didn’t strictly reference the /opt/pcre/bin directory we would get the following output.

# pcretest -C

PCRE version 8.12 2011-01-15
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

We tried adding custom build configuration to PHP to change the directory from /opt/pcre to /usr/local but this did not work following this documentation on the cpanel website http://docs.cpanel.net/twiki/bin/view/EasyApache3/CustomConfigureFlags

So what we did was download the latest source tarball from the PCRE website http://www.pcre.org/ and compile the package with the following configuration options as root.

# ./configure –prefix=/opt/pcre –enable-utf8 –enable-unicode-properties

# make

# make install

Then we restarted apache and voila the error message were gone and everything is working correctly under PHP 5.3.4.

2 Comments
  • web hosting
    August 16, 2011

    I added your article to my favorites so I can return to read more later. Your content is easy to read, intelligent and well written. I really enjoyed reading all the unique content you provided.

  • Manuel Alberto Perez
    April 5, 2013

    It was really useful and clear, however I have some extra problems, after restart the apache service. Here are all the steps I have taken in order to finally solve my issue:

    1) Download PCRE from http://www.pcre.org
    2) ./configure -prefix=/opt/pcre -€“enable-utf8 -€“enable-unicode-properties
    3) make
    4) make install
    5) echo “/opt/pcre/lib/” >> /etc/ld.so.conf
    6) ldconfig -v | grep -i pcre
    7) /scripts/easyapache –build
    8) restart httpd (I did it from cpanel)

    As you can see, almost as final I rebuild apache with easyapache in order to catch all configurations, now It is done, and all our sites are running fine again

    I found the additional steps in: http://stackoverflow.com/questions/9323228/phpinfo-is-reporting-incorrect-pcre-version
    Hope to be help for somebody else, best regards

    Manuel Alberto Perez

Write a Comment

Your email address will not be published. Required fields are marked *