无法在 PHP7 上安装 php-mysqli

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36387338/
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-26 00:48:08  来源:igfitidea点击:

Unable to install php-mysqli on PHP7

phpmysqlicentos

提问by Ryochan

I have installed PHP 7, mysql5.7, Apache2.2, CentOS6.

我已经安装了 PHP 7、mysql5.7、Apache2.2、CentOS6。

And I'm installing CodeIgniter3.0.6.

我正在安装 CodeIgniter3.0.6。

When I use database connection, error occured and said

当我使用数据库连接时,发生错误并说

A PHP Error was encountered

Severity: Core Warning

Message: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/php_mysqli.so' - /usr/lib64/php/modules/php_mysqli.so: cannot open shared object file: No such file or directory

Filename: Unknown

Line Number: 0

Of course there are no files in '/usr/lib64/php/modules/php_mysqli.so', but I don't know how to install mysqli.so.

当然'/usr/lib64/php/modules/php_mysqli.so'里面没有文件,但是我不知道如何安装mysqli.so。

I tried

我试过

yum install php-mysql

but

Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.riken.jp
 * extras: ftp.iij.ad.jp
 * remi-safe: mirror.awanti.com
 * updates: ftp.iij.ad.jp
Resolving Dependencies
--> Running transaction check
---> Package php-mysql.x86_64 0:5.3.3-46.el6_7.1 will be installed
--> Processing Dependency: php-common(x86-64) = 5.3.3-46.el6_7.1 for package: php-mysql-5.3.3-46.el6_7.1.x86_64
--> Finished Dependency Resolution
Error: Package: php-mysql-5.3.3-46.el6_7.1.x86_64 (updates)
           Requires: php-common(x86-64) = 5.3.3-46.el6_7.1
           Installed: php-common-7.0.4-1.el6.remi.x86_64 (@remi-php70)
               php-common(x86-64) = 7.0.4-1.el6.remi
           Available: php-common-5.3.3-40.el6_6.x86_64 (base)
               php-common(x86-64) = 5.3.3-40.el6_6
           Available: php-common-5.3.3-46.el6_6.x86_64 (updates)
               php-common(x86-64) = 5.3.3-46.el6_6
           Available: php-common-5.3.3-46.el6_7.1.x86_64 (updates)
               php-common(x86-64) = 5.3.3-46.el6_7.1
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

and it didn't work.

它没有用。



when I execute yum install php7.0-mysqlor yum install php70w-mysqlcommand,

当我执行yum install php7.0-mysqlyum install php70w-mysql命令时,

Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.riken.jp
 * extras: ftp.iij.ad.jp
 * remi-safe: mirror.awanti.com
 * updates: ftp.iij.ad.jp
No package php7.0-mysql available.
Error: Nothing to do

I don't know what to do at all.

我完全不知道该怎么办。

采纳答案by Remi Collet

Please remind that the mysqlextension is deprecatedand doesn't exists anymore with PHP 7.

请注意mysql扩展已弃用,PHP 7 中不再存在。

The php-mysqlndpackage provides only the mysqliand pdo_mysqlextensions.

PHP-mysqlnd包仅提供的mysqliPDO_MYSQL扩展。

The php-pecl-mysqlis also available, build from a git snapshot, provided for compatibility for legacy applications, but is not supported.

PHP的PECL-mysql的也可以,从git的快照,提供对旧有应用程序的兼容性的身材,但不支持。

From the original question:

从原来的问题:

Installed: php-common-7.0.4-1.el6.remi.x86_64 (@remi-php70)

安装:php-common-7.0.4-1.el6.remi.x86_64 (@remi-php70)

You have php 7.0.4 installed from remi-php70, but the repository is not enabled. You need to enabled it, so yum will find the right package matching the installed version.

您从remi-php70安装了 php 7.0.4 ,但未启用存储库。您需要启用它,因此 yum 会找到与安装版本匹配的正确软件包。

From the Configuration Wizardinstructions:

配置向导说明:

yum install yum-utils
yum-config-manager --enable remi-php70
yum install php-mysqlnd

Notice: the correct command to install an "foo" extension is yum install php-foo, so "yum install php-mysql" will install the package which provides the mysqlextension (so php-pecl-mysql), "yum install php-mysqli" will install the packages which provides the mysqliextension (so php-mysqlnd).

注意:安装“foo”扩展的正确命令是yum install php-foo,所以“yum install php-mysql”将安装提供mysql扩展的包(所以php-pecl-mysql),“yum install php- mysqli”将安装提供mysqli扩展的包(所以 php-mysqlnd)。

回答by Federkun

For PHP7, on CentOS/ RHEL:

对于 PHP7,在CentOS/ RHEL 上

yum install php70w-mysql

if you use the Remirepository

如果您使用Remi存储库

yum install php70-php-mysqlnd

for Ubuntu:

对于Ubuntu

apt-get install php7.0-mysql