PHP 8.1 - Rocky Linux 9 - preg_replace(): Compilation failed: unrecognised compile-time option bit(s) at offset 0

240 Views Asked by At

Setup

  • Rocky Linux 9
  • PHP 8.1
  • MySQL 8
  • Wordpress 6.2

I am attempting to install Wordpress on a brand new server I opened. But I'm getting the following warnings/errors when I visit the install page:

[18-May-2023 01:26:09 UTC] PHP Warning: preg_replace(): Compilation failed: unrecognised compile-time option bit(s) at offset 0 in /var/www/html/wp-includes/class-wpdb.php on line 1535
[18-May-2023 01:26:09 UTC] PHP Warning: preg_split(): Compilation failed: unrecognised compile-time option bit(s) at offset 0 in /var/www/html/wp-includes/class-wpdb.php on line 1538
[18-May-2023 01:26:09 UTC] PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, bool given in /var/www/html/wp-includes/class-wpdb.php:1540
Stack trace:
0 /var/www/html/wp-includes/option.php(199): wpdb->prepare()
1 /var/www/html/wp-includes/l10n.php(63): get_option()
2 /var/www/html/wp-includes/l10n.php(139): get_locale()
3 /var/www/html/wp-includes/l10n.php(868): determine_locale()
4 /var/www/html/wp-includes/class-wp-fatal-error-handler.php(47): load_default_textdomain()
5 [internal function]: WP_Fatal_Error_Handler->handle()
6 {main}
thrown in /var/www/html/wp-includes/class-wpdb.php on line 1540

After doing some error logging, I realized the fatal error is simply a result of the preg_replace() issue.

A similar question and other reading suggested that updating the libpcre2-8-0 package was the solve. I confirmed that package is on 10.40 and there are no pending updates I can install for any pcre package (On my system its called pcre2). According to this thats the latest version.

Is there anything I can do to fix this?

1

There are 1 best solutions below

0
On

I think installing the following packages fixed the problem in my case: yum install php-pear php-devel php-bcmath php-intl