Fatal error: Call to undefined function preg_match()

Today’s crazy error of the day is:

Fatal error: Call to undefined function preg_match() …

Wahoo! A built in function being undefined!

So how’s this possible? It seems that if you reinstall PHP without compiling in PCRE (Perl Compatible Regular Expressions), you can get this crazy error. It’s a flag you may need to manually enable.

8 thoughts on “Fatal error: Call to undefined function preg_match()”

  1. Thanks a lot for this !!! I have fixed the problem with my WordPress installation!!!

  2. ooops – typo in graceful !!

    Should be

    cd /usr/ports/devel/php5-pcre
    make deinstall rmconfig clean
    make build
    make install
    make clean
    apachectl graceful

  3. @Till,

    Thanks for this post! I tried my best to get my FreeBSD server running after updating to PHP 5.2.10

    I would just recommend adding the following step in to ensure you start from scratch:

    make rmconfig – will remove your old user config settings.

    So the steps will be:

    cd /usr/ports/devel/php5-pcre
    make deinstall rmconfig clean
    make build
    make install
    make clean
    apachectl gracefull

    Last line is a more gracefull way of restarting Apache.

  4. Till, I appreciate you too! -)) Faced this issue after #portupgrade -aRr .
    Now all is OK.

  5. Thanks a zillion I was going nutz. I was also have trouble with some pages with php just showing blank pages.

    I was on freebsd 7.0 and also had just done a portupgrade of a bunch of packages so I had no idea where to start looking. rebuilding /devel/php5-pcre did the trick.

    Thanks again for posting.

  6. Till,

    Much appreciate this post…been trying fix PCRE on my FreeBSD 7 box for about 3 hours now. Thanks for the info, got my phpMyAdmin and Gallery setup working again.

    cd /usr/ports/devel/php5-pcre
    make deinstall clean
    make build
    make install
    /usr/local/etc/rc.d/apache22 restart

    Thanks!

    -David

  7. Just for documentation — on FreeBSD you can get this error after portupdating to PHP 5.2.9. So even though I rebuild lang/php5 and lang/php5-extensions completely and it claimed I had installed devel/php5-pcre, the fix is to rebuild devel/php5-pcre (don’t forget to restart Apache afterwards).

Comments are closed.