Mac OS:未加载国际扩展 [英] Mac OS: Intl extension is not loaded

查看:136
本文介绍了Mac OS:未加载国际扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • macOS Mojave 10.14.3
  • PHP 7.1.23
  • Prestashop 1.7.5.1

我试图在本地服务器上安装PHP intl扩展,以便使用Prestashop.

I tried to install PHP intl extension on my local server in order to use Prestashop.

我已将extension=php_intl.so添加到etc/php.ini

当我尝试安装Prestashop时,我会得到Intl extension is not loaded.

When I try to install Prestashop I get Intl extension is not loaded.

当我执行$ php -m | grep intl时,我得到:

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/pecl/20160303/php_intl.so' - d lopen(/usr/local/lib/php/pecl/20160303/php_intl.so, 9): image not found in Unknown on line 0 Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/pecl/20160303/php_intl.so' - dlopen (/usr/local/lib/php/pecl/20160303/php_intl.so, 9): image not found in Unknown on line 0 intl

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/pecl/20160303/php_intl.so' - d lopen(/usr/local/lib/php/pecl/20160303/php_intl.so, 9): image not found in Unknown on line 0 Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/pecl/20160303/php_intl.so' - dlopen (/usr/local/lib/php/pecl/20160303/php_intl.so, 9): image not found in Unknown on line 0 intl

似乎文件php_intl.so不存在.

我也尝试了$ sudo pecl install intl,我得到了:

I also tried $ sudo pecl install intland I get:

make: *** [php_intl.lo] Error 1 ERROR: make'失败`

make: *** [php_intl.lo] Error 1 ERROR:make' failed`

我也尝试过$ curl -s http://php-osx.liip.ch/install.sh | bash -s 7.1,它没有创建intl.so文件.

I also tried $ curl -s http://php-osx.liip.ch/install.sh | bash -s 7.1 and it doesn't create the intl.so file.

我该如何解决这个问题?

How can I solve this problem?

推荐答案

Brew的PHP 7.1、7.2和7.3 默认情况下都启用了INTL .

Brew's PHP 7.1, 7.2 and 7.3 all have INTL enabled by default.

很可能您只是使用Mac OS的捆绑软件版本的PHP.

Most probably, you're just using your Mac OS' bundles version of PHP.

运行

ls -l $(which php)

查找当前PHP二进制文件的位置以及是否将其符号链接到Brew安装.以我为例,例如:

to find out where the current PHP binary is located and whether it is symlinked to a Brew installation or not. In my case, for example:

lrwxr-xr-x 1 27 May 23 16:30 /usr/local/bin/php -> ../Cellar/php/7.3.5/bin/php

这意味着我的php已链接到Brew的7.3.5版本.

Meaning that my php is linked to Brew's 7.3.5 version.

如果您使用Brew的PHP,则会看到类似的内容

If you are NOT using Brew's PHP, you'll see something like

-rwxr-xr-x 1 11169664 Mar 21 07:09 /usr/bin/php

通过Brew安装PHP

了解您是否已经安装了PHP:

Installing PHP through Brew

Find out whether you've already installed PHP:

brew list | grep php

如果有任何输出,并且存在您的PHP版本,请转到步骤2,或使用步骤1将PHP更新到最新版本.

If there is any output, and your version of PHP is present, go to step 2, or use step 1 to update PHP to the latest version.

1.安装Homebrew的PHP

brew install php@7.3

(或7.2、7.1).如果Brew抱怨无法找到公式,则可能是水龙头搞砸了.代替php@7.3,您可以尝试提供当前php公式的完整路径:

(or 7.2, 7.1). If Brew complains about not being able to find a formula, you might have messed with taps. Instead of php@7.3, you could try to supply the full path to the current php formula:

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/php.rb

仍然无法正常工作,请检查您是否正在运行Homebrew brew --version的最新版本.

Still not working, check whether you are running a recent version of Homebrew brew --version.

Homebrew 2.1.3-31-geaf2370
Homebrew/homebrew-core (git revision fd1ef; last commit 2019-05-25)
Homebrew/homebrew-cask (git revision 16d50; last commit 2019-05-26)

2.链接Homebrew的PHP

现在,要在路径中添加php,有两种选择.

Now, to have php 'in your path', there are two options.

a) 任一自制软件的版本都必须从其安装位置(/usr/local/bin/Cellar/php ... .)到您路径中的目录(例如/usr/local/bin).为此,请运行:

a) Either homebrew's version must be linked from its install location (/usr/local/bin/Cellar/php....) to a directory in your path (e.g., /usr/local/bin). To do this, run:

brew link --force php@7.3

如果无法链接,通常是由设置权限或系统完整性保护引起的.在第一种情况下,请尝试sudo chown "$USER":admin /usr/local/bin/php.

If you are not able to link, this is typically caused by set permissions or System Integrity Protection. In the first case, try sudo chown "$USER":admin /usr/local/bin/php.

b) ,添加/usr/local/opt/php@7.3目录( 选择前缀 )添加到您的$ PATH变量中.例如,重击:

echo 'export PATH="/usr/local/opt/php@7.3/bin:/usr/local/opt/php@7.3/sbin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile

3.验证安装

ls -l $(which php)

应显示php链接到/usr/local/bin/Cellar中的Homebrew PHP安装.

should show that php is linked to a Homebrew PHP installation in /usr/local/bin/Cellar.

php -v

应显示最近安装的PHP版本.如果不是这种情况,请尝试重新启动终端.

should show the recently installed version of PHP. Try to restart your terminal if that's not the case.

php -i | grep -i intl

应显示有关当前安装的intl的一些信息.

should show some information about the current install of intl.

如果您使用的是Web服务器和/或PHP FPM,则该重新启动这些服务了. (或者,如果您不知道如何操作并且无法找出原因,请重新启动系统).

If you're using webservers and/or PHP FPM, this is the time to restart those services. (Or restart your system, if you don't know how to do that and cannot figure out).

如果仍然收到有关缺少扩展名的警告(无法加载动态库等),则说明您的php.ini混乱了.

找到php ini的当前位置

Find the current location of php's ini

$ php -i | grep \.ini

Configuration File (php.ini) Path => /usr/local/etc/php/7.3
Loaded Configuration File => /usr/local/etc/php/7.3/php.ini
Scan this dir for additional .ini files => /usr/local/etc/php/7.3/conf.d
Additional .ini files parsed => /usr/local/etc/php/7.3/conf.d/ext-opcache.ini
....

编辑/usr/local/etc/php/7.3/php.ini并查找有问题的扩展负载(例如extension="myext.so").注释掉那些找不到的东西.

Edit /usr/local/etc/php/7.3/php.ini and find the offending extension load (e.g., extension="myext.so"). Comment out those that cannot be found.

自制程序权限

有人认为称赞/usr/local是个好主意.

sudo chown -R "$USER":admin /usr/local

这将使手动和通过Homebrew进行安装变得容易得多,但同时也降低了安全性,因为现在也允许在非root进程中进行写操作.

This will make installing things here, by hand and through Homebrew, a lot easier, but also a bit less secure too, since non-root processes are now allowed to write here too.

您的网络应用程序使用的是其他版本的PHP.

请确保它没有...此配置取决于所用的Web服务器.第一步是使用<?php phpinfo();在Web应用程序中输出当前PHP配置.

Make sure that it doesn't... The configuration of this depends on the used webserver. A first step would be to output the current PHP configuration in your web-application with <?php phpinfo();.

这说明了适用于Apache的步骤.

使网络服务器+ PHP堆栈快速运行的另一种方法是使用 Laravel Valet .

Another way to get a webserver + PHP stack running quicly is using Laravel Valet.

要安装其他PHP扩展,请使用PEAR.

To install additional PHP extensions, use PEAR.

pear -V 应该输出当前的PEAR和PHP版本.

pear -V should output the current PEAR and PHP version.

PEAR Version: 1.10.9
PHP Version: 7.3.5
Zend Engine Version: 3.3.5

现在,要安装扩展,例如PHP的yaml扩展:

Now, to install an extension, for example, PHP's yaml extension:

pear install yaml

这篇关于Mac OS:未加载国际扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆