简体   繁体   中英

PHP module shows in php cli, not in Apache (XAMPP, Mac OS Mojave)

I have managed to enable the intl module on my machine (it was quite tricky), and when I do php -m | grep intl php -m | grep intl I see the module listed. My problem is that it seems the module is enabled, but still XAMPP is probably loading some other version of PHP where it isn't.

The output of which php is:

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

The output of php -v is:

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

Output of php -i | grep intl php -i | grep intl is:

Configure Command => './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-soap' '--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/Contents/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.platf orm/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 => no value => no value intl.error_level => 0 => 0 intl.use_exceptions => 0 => 0

These are the paths in my bash profile:

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

Then, in php.ini I uncommented this line:

extension=intl.so

xdebug is also enabled:

; Enable 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

In httpd.conf , I load the PHP module like this:

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

I've checked that httpd.conf is not being included in an additional file (as suggested by this answer ). I got this:

Include "/Applications/XAMPP/xamppfiles/apache2/conf/httpd.conf"

But that additional config file only contains virtual directories.

My phpinfo spits this PHP version:

PHP Version 7.1.13

I've read that PHP cli and PHP module for Apache2 don't necessarily have the same version, but here's my question:

why the intl module is loaded correctly in PHP cli and not in the Apache2 PHP module?

PS: There are no errors in the logs about loading an incorrect module, there were before I renamed it from php_intl.dll to intl.so , but not anymore.

XAMPP has its own bundled Apache+PHP. it runs php as apache module.

to run php as apache module, you should re-compile mod php from source with parameter --with-apxs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM