PHP 5.4 安装后:preg_match():编译失败:在偏移量 0 处设置未知选项位


PHP 5.4 after-install: preg_match(): Compilation failed: unknown option bit(s) set at offset 0

我最近在我的Lion OS X 64位上将PHP升级到5.4.1版本,我在Codeigniter中抛出了一个错误:

Severity: Warning
Message: preg_match(): Compilation failed: unknown option bit(s) set at offset 0
Filename: core/Utf8.php
Line Number: 44

我在谷歌上搜索了这个问题,这似乎是 PHP 中 PCRE 库的问题,好吧,我按照本教程进行操作,该教程显示了使用我所做的自制软件安装 pcre(我正在运行 pcre 8.30),但这并没有解决问题。

我尝试四处寻找解决方案,但我还没有遇到有帮助的解决方案 - 有没有办法解决这个 PCRE 库问题?

编辑:

刚刚编辑了这个问题,以提醒我我的安装是什么:

./configure '
--prefix=/usr '
--mandir=/usr/share/man '
--infodir=/usr/share/info '
--sysconfdir=/private/etc '
--with-apxs2=/usr/sbin/apxs '
--enable-cli '
--with-config-file-path=/etc '
--with-libxml-dir=/usr '
--with-openssl=/usr '
--with-kerberos=/usr '
--with-zlib=/usr '
--enable-bcmath '
--with-bz2=/usr '
--enable-calendar '
--with-curl=/usr '
--enable-dba '
--enable-exif '
--enable-ftp '
--with-gd '
--with-freetype-dir=/usr/X11/ '
--with-jpeg-dir=/usr '
--with-png-dir=/usr/X11/ '
--enable-gd-native-ttf '
--with-icu-dir=/usr '
--with-iodbc=/usr '
--with-ldap=/usr '
--with-ldap-sasl=/usr '
--with-libedit=/usr '
--enable-mbstring '
--enable-mbregex '
--with-mysql=mysqlnd '
--with-mysqli=mysqlnd '
--with-pdo-mysql=mysqlnd '
--with-mysql-sock=/var/mysql/mysql.sock '
--with-readline=/usr '
--enable-shmop '
--with-snmp=/usr '
--enable-soap '
--enable-sockets '
--enable-sysvmsg '
--enable-sysvsem '
--enable-sysvshm '
--with-tidy '
--enable-wddx '
--with-xmlrpc '
--with-iconv-dir=/usr '
--with-xsl=/usr '
--enable-zip '
--with-pgsql=/usr '
--with-pdo-pgsql=/usr '
--with-mcrypt=/usr/local/lib
我能够让 PHP 5.4.1

与 PCRE 版本 8.12 一起使用(我相信这是 PHP 5.4.1 中包含的版本)。 在问题评论中列出的所有来回之后,我决定在没有 PCRE 标志的情况下编译 PHP,让 PHP 只使用它的默认值。通过使用默认值,它使用 8.12 进行编译。

现在,一个后续问题当然是为什么会发生这种情况。我仍然希望 8.30 使用我提供的标志使用 PHP 进行编译。但是,在这一点上,我很高兴让事情发挥作用。

以下是我必须工作的配置选项,以防您想从您的终端尝试它。

./configure '
--prefix=/usr '
--mandir=/usr/share/man '
--infodir=/usr/share/info '
--sysconfdir=/private/etc '
--with-apxs2=/usr/local/apache/bin/apxs '
--enable-cli '
--with-config-file-path=/etc '
--with-libxml-dir=/usr '
--with-openssl=/usr '
--with-kerberos=/usr '
--with-zlib=/usr '
--enable-bcmath '
--with-bz2=/usr '
--enable-calendar '
--with-curl=/usr '
--enable-dba '
--enable-exif '
--enable-ftp '
--with-gd '
--with-freetype-dir=/usr/X11/ '
--with-jpeg-dir=/usr '
--with-png-dir=/usr/X11/ '
--enable-gd-native-ttf '
--with-icu-dir=/usr '
--with-iodbc=/usr '
--with-ldap=/usr '
--with-ldap-sasl=/usr '
--with-libedit=/usr '
--enable-mbstring '
--enable-mbregex '
--with-mysql=mysqlnd '
--with-mysqli=mysqlnd '
--with-pdo-mysql=mysqlnd '
--with-mysql-sock=/var/mysql/mysql.sock '
--with-readline=/usr '
--enable-shmop '
--with-snmp=/usr '
--enable-soap '
--enable-sockets '
--enable-sysvmsg '
--enable-sysvsem '
--enable-sysvshm '
--with-tidy '
--enable-wddx '
--with-xmlrpc '
--with-iconv-dir=/usr '
--with-xsl=/usr '
--enable-zip '
--with-pgsql=/usr '
--with-pdo-pgsql=/usr '
--with-mcrypt=/usr

我通过使用yum update更新Linux机器上的PHP和PCRE解决了这个问题。

PHP 已更新到版本

5.3.17,PCRE 已更新到版本 8.21-5.3amzn1(我在 Amazon EC2 实例上运行)。

重新编译 httpd。在此之前,请确保您的系统上只有一个版本的pcre。

我的解决方案接近@bigZero提出的。

我无法让它在 brew 上运行,因为当我尝试在 brew 上安装 pcre v8.12 时,这是不可能的,因为它(可能)从存储库中删除了。我的意思是,它显示在brew versions pcre但是当我尝试安装它时,它无法从 ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/下载

所以我不得不从 http://www.pcre.org 下载pcre 8.12源代码,编译并安装它。我使用了以下配置:./configure --prefix=/usr --enable-utf8 --enable-unicode-properties

我尝试在没有--with-pcre-regex选项的情况下重新编译 php(在我的例子中为 5.4.10)(如 @scott-harwell 所建议的那样。但它在编译时失败了。比我添加--with-pcre-regex=/usr/,它终于奏效了。