首页 > 解决方案 > PHP 模块显示在 php cli 中,而不是 Apache(XAMPP,Mac OS Mojave)

问题描述

我已经设法在我的机器上启用了 intl 模块(这很棘手),当我这样做时,php -m | grep intl我看到了列出的模块。我的问题是该模块似乎已启用,但 XAMPP 可能仍在加载其他版本的 PHP,但它不是。

的输出which php是:

/usr/local/opt/php@7.1/bin/php

的输出php -v是:

PHP 7.1.26 (cli) (built: Feb 26 2019 10:26:24) (NTS) 版权所有 (c) 1997-2018 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.1.26,版权所有 (c) 1999-2018,由 Zend Technologies 提供

的输出php -i | grep intl是:

配置命令 => './configure' '--prefix=/usr/local/Cellar/php@7.1/7.1.26' ' '--localstatedir=/usr/local/var' ' '--sysconfdir=/usr/local /etc/php/7.1' '--with-config-file-path=/usr/local/etc/php/7.1' '--with-config-file-scan-dir=/usr/local/etc/php /7.1/conf.d' '--with-pear=/usr/local/Cellar/php@7.1/7.1.26/share/php@7.1/pear' '--enable-bcmath' '--enable-calendar ' '--enable-dba' '--enable-dtrace' '--enable-exif' '--enable-ftp' '--enable-fpm' '--enable-intl' '--enable-mbregex' '--enable-mbstring' '--enable-mysqlnd' '--enable-opcache-file' '--enable-pcntl' '--enable-phpdbg' '--enable-phpdbg-webhelper' '--enable -shmop''--启用肥皂''--enable-sockets' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--enable-wddx' '--enable-zip' '--with-apxs2=/usr /local/opt/httpd/bin/apxs'''--with-bz2=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr'''-- with-curl=/usr/local/opt/curl-openssl''--with-fpm-user=_www''--with-fpm-group=_www'''--with-freetype-dir=/usr/local /opt/freetype' '--with-gd' '--with-gettext=/usr/local/opt/gettext' '--with-gmp=/usr/local/opt/gmp' '--with-iconv =/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr''--with-icu-dir=/usr/local/opt/icu4c''- -with-jpeg-dir=/usr/local/opt/jpeg''--with-kerberos=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr' '--with-layout=GNU' '--with-ldap =/usr/local/opt/openldap''--with-ldap-sasl=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr''- -with-libedit=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr''--with-libxml-dir=/Applications/Xcode.app/目录/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr''--with-libzip''--with-mcrypt=/usr/local/opt/mcrypt''--with- mhash=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr''--with-mysql-sock=/tmp/mysql.sock''--with-mysqli=mysqlnd' '--with-ndbm=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr' '--with-openssl =/usr/local/opt/openssl''--with-pdo-dblib=/usr/local/opt/freetds'''--with-pdo-mysql=mysqlnd'''--with-pdo-odbc=unixODBC, /usr/local/opt/unixodbc' '--with-pdo-pgsql=/usr/local/opt/libpq' '--with-pdo-sqlite=/usr/local/opt/sqlite' '--with- pgsql=/usr/local/opt/libpq' '--with-pic' '--with-png-dir=/usr/local/opt/libpng' '--with-pspell=/usr/local/opt/ aspell' '--with-sqlite3=/usr/local/opt/sqlite' '--with-tidy=/usr/local/opt/tidy-html5' '--with-unixODBC=/usr/local/opt/ unixodbc' '--with-webp-dir=/usr/local/opt/webp' '--with-xmlrpc' '--with-xsl=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr' '--with-zlib=/Applications/Xcode.app/Contents /Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr' intl intl.default_locale => 没有值 => 没有值 intl.error_level => 0 => 0 intl.use_exceptions => 0 => 0

这些是我的 bash 配置文件中的路径:

导出 PATH="/usr/local/opt/php@7.1/bin:$PATH" 导出 PATH="/usr/local/opt/php@7.1/sbin:$PATH"

然后,在php.ini我取消注释这一行:

扩展名=intl.so

xdebug也启用:

; 启用 xdebug zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so" xdebug.remote_enable=on xdebug.remote_handler=dbgp xdebug.remote_host=localhost xdebug.remote_port=9000 xdebug。 max_nesting_level=500

httpd.conf中,我像这样加载 PHP 模块:

LoadModule php7_module /usr/local/opt/php@7.1/lib/httpd/modules/libphp7.so

我已经检查过 httpd.conf 没有包含在附加文件中(如this answer建议的那样)。我懂了:

包括“/Applications/XAMPP/xamppfiles/apache2/conf/httpd.conf”

但是那个额外的配置文件只包含虚拟目录。

我的 phpinfo 吐出这个 PHP 版本:

PHP 版本 7.1.13

我读过 Apache2 的 PHP cli 和 PHP 模块不一定具有相同的版本,但这是我的问题:

为什么 intl 模块在 PHP cli 中正确加载,而不是在 Apache2 PHP 模块中?

PS:日志中没有关于加载不正确模块的错误,在我将其重命名之前有php_intl.dllintl.so但现在没有了。

标签: phpmacosapachemoduleintl

解决方案


XAMPP 有自己捆绑的 Apache+PHP。它运行 php 作为 apache 模块。

要将 php 作为 apache 模块运行,您应该使用参数 --with-apxs 从源代码重新编译 mod php。


推荐阅读