如何在 CentOS 上安装 PHP intl 扩展?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14679990/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 07:47:28  来源:igfitidea点击:

How do I install PHP intl extension on CentOS?

phpcentosinstallyumphp-extension

提问by toxalot

I know virtually nothing about installing packages. I managed to install Zend Framework 1 with yum a while back by following a very specific tutorial.

我对安装软件包几乎一无所知。不久前,我按照非常具体的教程设法使用 yum 安装了 Zend Framework 1。

Now I need the PHP intl extension and I can't figure out how to install it.

现在我需要 PHP intl 扩展,但我不知道如何安装它。

I did

我做了

yum list php*intl

and saw that there was one available. So I did

并看到有一个可用。所以我做了

yum install php-intl

and got the following error message:

并收到以下错误消息:

Error: Package: php-intl-5.3.3-14.el6_3.x86_64 (updates)
       Requires: php-common = 5.3.3-14.el6_3
       Installed: php-common-5.3.17-2.el6.remi.x86_64 (@remi)
           php-common = 5.3.17-2.el6.remi
       Available: php-common-5.3.3-3.el6_2.8.x86_64 (base)
           php-common = 5.3.3-3.el6_2.8
       Available: php-common-5.3.3-14.el6_3.x86_64 (updates)
           php-common = 5.3.3-14.el6_3
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

I did not try the suggestions mentioned in the message because I didn't know what they would do and I am afraid of breaking something. This is a production machine and I don't have another machine to test on. I tried to find an rpm to download that was the same version as my PHP, but had no luck.

我没有尝试消息中提到的建议,因为我不知道他们会做什么,而且我害怕破坏某些东西。这是一台生产机器,我没有另一台机器可以测试。我试图找到一个与我的 PHP 版本相同的 rpm 下载,但没有运气。

What do those two suggestions do and are they safeto try? What else can I try to get the intl extension installed?

这两个建议有什么作用,尝试它们是否安全?我还能尝试安装 intl 扩展吗?

回答by Carlos Romero López

As you have php-commom from remi repositories, you need to get php-intl from remi also.

由于您有来自 remi 存储库的 php-commom,您还需要从 remi 获取 php-intl。

Add --enable-repooption as follows:

添加--enable-repo选项如下:

yum --enablerepo=remi install php-intl

回答by Christos Lytras

If you have higher PHP version like 5.6, you have to enable both remiand remi-php56repos to install all the additional dependencies:

如果你有更高的 PHP 版本,比如 5.6,你必须同时启用remiremi-php56repos 来安装所有额外的依赖项:

yum --enablerepo=remi,remi-php56 install php-intl

回答by Faisal

I successfully installed INTL via pecl using following steps.

我使用以下步骤通过 pecl 成功安装了 INTL。

1) install icu & libs:

1)安装icu和libs:

yum -y install icu libicu libicu-devel

yum -y install icu libicu libicu-devel

2) php-devel package and phpize:

2) php-devel 包和 phpize:

yum -y install php-devel phpize

yum -y install php-devel phpize

3) and, of course gcc:

3)当然还有gcc:

yum -y install gcc gcc-cpp gcc-c++

yum -y install gcc gcc-cpp gcc-c++

This is working for me.my php version is 5.6.12

这对我有用。我的 php 版本是 5.6.12

回答by Fernando Valler

for php 7.0 using

对于 php 7.0 使用

#list all options    
$ sudo yum list php7*intl

#install
$ sudo yum install php70-intl

回答by jtherkel

Yum is throwing an error because we are attempting to update multiple packages to versions that conflict. Your yum output says that php-intl requires a specific version of the php-common. Removing all the junk:

Yum 正在抛出错误,因为我们正在尝试将多个包更新到冲突的版本。您的 yum 输出表明 php-intl 需要特定版本的 php-common。删除所有垃圾:

Requires 5.3.3-14
Installed 5.3.17-2
Available 1st Option: 5.3.3-3
Available 2nd Option: 5.3.3-14

This tells us that you already have installed a more recent version of php-common (5.3.17-2) than is allowed by php-intl.

这告诉我们您已经安装了比 php-intl 允许的更新版本的 php-common (5.3.17-2)。

I think you have two options. (As a newbie myself, I would not attempt these without practicing in a dev environment.)

我认为你有两个选择。(作为我自己的新手,如果没有在开发环境中练习,我不会尝试这些。)

1) Remove remi Packages

1) 移除 remi 包

Quoting from a similar question on Super User. "Try removing all remi php packages, disable remi repository and install the default centos 6 php 5.3.3 packages."

引用超级用户上的类似问题。“尝试删除所有 remi php 包,禁用 remi 存储库并安装默认的 centos 6 php 5.3.3 包。”

https://superuser.com/questions/505340/centos-6-how-to-install-php-mysql-when-php-common-remi-is-present

https://superuser.com/questions/505340/centos-6-how-to-install-php-mysql-when-php-common-remi-is-present

2) Downgrade php-common to Version 5.3.3-14

2) 将 php-common 降级到 5.3.3-14 版本

yum downgrade php-common

I have no idea if you would run into more dependency issues and have to downgrade other packages. I found more details here.

我不知道您是否会遇到更多依赖问题并不得不降级其他软件包。我在这里找到了更多细节。

https://www.centos.org/modules/newbb/viewtopic.php?topic_id=40567&forum=56

https://www.centos.org/modules/newbb/viewtopic.php?topic_id=40567&forum=56

Other Stack Exchange sites show similar questions.

其他 Stack Exchange 站点显示了类似的问题。

https://serverfault.com/search?q=centos+error+package(370 results)

https://serverfault.com/search?q=centos+error+package(370 结果)

https://unix.stackexchange.com/search?q=centos+error+package(57 results)

https://unix.stackexchange.com/search?q=centos+error+package(57个结果)