简体   繁体   中英

How do I install PHP intl extension on CentOS?

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.

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

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.

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

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

Add --enable-repo option as follows:

yum --enablerepo=remi install php-intl

如果你有更高的PHP版本5.6一样,你必须同时启用remiremi-php56回购全部安装额外的依赖关系:

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

I successfully installed INTL via pecl using following steps.

1) install icu & libs:

yum -y install icu libicu libicu-devel

2) php-devel package and phpize:

yum -y install php-devel phpize

3) and, of course gcc:

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

This is working for me.my php version is 5.6.12

for php 7.0 using

#list all options    
$ sudo yum list php7*intl

#install
$ sudo yum install php70-intl

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:

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.

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

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."

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

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

Other Stack Exchange sites show similar questions.

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

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

To elaborate just a little on @Fernando Valler 's answer.

On my Fedora 35 machine, I have multiple installs of php. To check how many, I use a tool by Symfony (I am not sure how to do otherwise so quickly):

 $ symfony local:php:list
 +---------+--------------------------+---------+ 
 | Version |        Directory         |   PHP   |    
 +---------+--------------------------+---------+ 
 | 7.4.30  | /opt/remi/php74/root/usr | bin/php | 
 | 8.0.22  | /usr                     | bin/php |  
 | 8.1.10  | /opt/remi/php81/root/usr | bin/php |  
 +---------+--------------------------+---------+ 

Say I miss intl for version 8.1.10. First check whether intl.so is indeed not within its modules directory: php81 -r "echo ini_get('extension_dir');" .

To install it, check packages by dnf list php*intl , you get something like:

$sudo dnf list php*intl
Installed Packages
php-intl.x86_64  8.0.22-1.fc35  @updates
Available Packages
php-intl.x86_64   8.0.23-1.fc35  updates 
php-symfony-intl.noarch  2.8.52-7.fc35  fedora  
php-symfony3-intl.noarch  3.4.49-2.fc35 fedora  
...
php72-php-intl.x86_64  7.2.34-11.fc35.remi  remi    
php81-php-intl.x86_64  8.1.10-1.fc35.remi  remi    
php82-php-intl.x86_64  8.2.0~rc2-15.fc35.remi  remi 

Select what you need, say for php8.1.10 , and install intl extension for it: sudo dnf install php81-php-intl . It will pop up within the modules directory for php 8.1.

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