尝试在已安装 MariaDB 的情况下安装 PHP MySQL 驱动程序

尝试在已安装 MariaDB 的情况下安装 PHP MySQL 驱动程序

我有一个 VPS,它来自一个名为CentOS 6.4 x64,Nginx,php-fpm,MariaDB。PHP 和 MariaDB 都已安装,但 PHP 似乎没有安装 MySQL 驱动程序。我首先尝试添加

extension=mysql.so

但这php.ini给了我以下错误:

Starting php-fpm: [12-Dec-2013 17:23:27] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/mysql.so' - /usr/lib64/php/modules/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0

然后我尝试了一下yum install php-mysql,但得到以下结果:

Resolving Dependencies
--> Running transaction check
---> Package php-mysql.x86_64 0:5.4.23-1.el6.remi will be installed
--> Processing Dependency: php-pdo(x86-64) = 5.4.23-1.el6.remi for package: php-mysql-5.4.23-1.el6.remi.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: php-mysql-5.4.23-1.el6.remi.x86_64
Package mysql-libs-5.5.35-1.el6.remi.x86_64 is obsoleted by MariaDB-shared-5.5.32-1.i386 which is already installed
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_16)(64bit) for package: php-mysql-5.4.23-1.el6.remi.x86_64
Package mysql-libs-5.5.35-1.el6.remi.x86_64 is obsoleted by MariaDB-shared-5.5.32-1.i386 which is already installed
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: php-mysql-5.4.23-1.el6.remi.x86_64
Package mysql-libs-5.5.35-1.el6.remi.x86_64 is obsoleted by MariaDB-shared-5.5.32-1.i386 which is already installed
--> Finished Dependency Resolution
Error: Package: php-mysql-5.4.23-1.el6.remi.x86_64 (remi)
           Requires: libmysqlclient.so.18()(64bit)
           Available: compat-mysql55-5.5.11-1.el6.remi.x86_64 (remi-test)
               libmysqlclient.so.18()(64bit)
           Available: compat-mysql55-5.5.34-1.el6.remi.x86_64 (remi-test)
               libmysqlclient.so.18()(64bit)
           Available: mysql-libs-5.5.34-1.el6.remi.x86_64 (remi)
               libmysqlclient.so.18()(64bit)
           Available: mysql-libs-5.5.35-1.el6.remi.x86_64 (remi)
               libmysqlclient.so.18()(64bit)
           Available: mysql-libs-5.1.71-1.el6.i686 (base)
               Not found
Error: Package: php-mysql-5.4.23-1.el6.remi.x86_64 (remi)
           Requires: libmysqlclient.so.18(libmysqlclient_16)(64bit)
           Available: compat-mysql55-5.5.11-1.el6.remi.x86_64 (remi-test)
               libmysqlclient.so.18(libmysqlclient_16)(64bit)
           Available: compat-mysql55-5.5.34-1.el6.remi.x86_64 (remi-test)
               libmysqlclient.so.18(libmysqlclient_16)(64bit)
           Available: mysql-libs-5.5.34-1.el6.remi.x86_64 (remi)
               libmysqlclient.so.18(libmysqlclient_16)(64bit)
           Available: mysql-libs-5.5.35-1.el6.remi.x86_64 (remi)
               libmysqlclient.so.18(libmysqlclient_16)(64bit)
           Available: mysql-libs-5.1.71-1.el6.i686 (base)
               Not found
Error: Package: php-mysql-5.4.23-1.el6.remi.x86_64 (remi)
           Requires: libmysqlclient.so.18(libmysqlclient_18)(64bit)
           Available: compat-mysql55-5.5.11-1.el6.remi.x86_64 (remi-test)
               libmysqlclient.so.18(libmysqlclient_18)(64bit)
           Available: compat-mysql55-5.5.34-1.el6.remi.x86_64 (remi-test)
               libmysqlclient.so.18(libmysqlclient_18)(64bit)
           Available: mysql-libs-5.5.34-1.el6.remi.x86_64 (remi)
               libmysqlclient.so.18(libmysqlclient_18)(64bit)
           Available: mysql-libs-5.5.35-1.el6.remi.x86_64 (remi)
               libmysqlclient.so.18(libmysqlclient_18)(64bit)
           Available: mysql-libs-5.1.71-1.el6.i686 (base)
               Not found
Error: Package: php-mysql-5.4.23-1.el6.remi.x86_64 (remi)
           Requires: php-pdo(x86-64) = 5.4.23-1.el6.remi
           Installed: php-pdo-5.5.0-1.el6.remi.x86_64 (@remi-test)
               php-pdo(x86-64) = 5.5.0-1.el6.remi
           Available: php-pdo-5.3.3-26.el6.x86_64 (base)
               php-pdo(x86-64) = 5.3.3-26.el6
           Available: php-pdo-5.3.3-27.el6_5.x86_64 (updates)
               php-pdo(x86-64) = 5.3.3-27.el6_5
           Available: php-pdo-5.4.22-1.el6.remi.x86_64 (remi)
               php-pdo(x86-64) = 5.4.22-1.el6.remi
           Available: php-pdo-5.4.23-1.el6.remi.x86_64 (remi)
               php-pdo(x86-64) = 5.4.23-1.el6.remi
 You could try using --skip-broken to work around the problem
** Found 3 pre-existing rpmdb problem(s), 'yum check' output follows:
2:postfix-2.6.6-2.2.el6_1.x86_64 has missing requires of libmysqlclient.so.16()(64bit)
2:postfix-2.6.6-2.2.el6_1.x86_64 has missing requires of libmysqlclient.so.16(libmysqlclient_16)(64bit)
2:postfix-2.6.6-2.2.el6_1.x86_64 has missing requires of mysql-libs

我该怎么办?当然我不想安装 MySQL 本身,只想安装 PHP 驱动程序。

注:本文转自https://stackoverflow.com/questions/20561527/install-php-mysql-to-use-mariadb但也许它实际上比 StackOverflow 更适合这里

更新 1

在 John 的建议下,我尝试了yum install php-mysql --disablerepo=remi。然而这仍然给我带来了更多问题:

Error: Package: php-mysql-5.3.3-27.el6_5.x86_64 (updates)
           Requires: libmysqlclient.so.16(libmysqlclient_16)(64bit)
           Available: mysql-libs-5.1.71-1.el6.x86_64 (base)
               libmysqlclient.so.16(libmysqlclient_16)(64bit)
Error: Package: php-mysql-5.3.3-27.el6_5.x86_64 (updates)
           Requires: libmysqlclient.so.16()(64bit)
           Available: mysql-libs-5.1.71-1.el6.x86_64 (base)
               libmysqlclient.so.16()(64bit)
Error: Package: php-mysql-5.3.3-27.el6_5.x86_64 (updates)
           Requires: php-common(x86-64) = 5.3.3-27.el6_5
           Installed: php-common-5.5.0-1.el6.remi.x86_64 (@remi-test)
               php-common(x86-64) = 5.5.0-1.el6.remi
           Available: php-common-5.3.3-26.el6.x86_64 (base)
               php-common(x86-64) = 5.3.3-26.el6
           Available: php-common-5.3.3-27.el6_5.x86_64 (updates)
               php-common(x86-64) = 5.3.3-27.el6_5

更新 2

如果我尝试,yum install php-mysqlnd那么依赖性错误就会减少:

Error: Package: php-mysqlnd-5.4.23-1.el6.remi.x86_64 (remi)
           Requires: php-pdo(x86-64) = 5.4.23-1.el6.remi
           Installed: php-pdo-5.5.0-1.el6.remi.x86_64 (@remi-test)
               php-pdo(x86-64) = 5.5.0-1.el6.remi
           Available: php-pdo-5.3.3-26.el6.x86_64 (base)
               php-pdo(x86-64) = 5.3.3-26.el6
           Available: php-pdo-5.3.3-27.el6_5.x86_64 (updates)
               php-pdo(x86-64) = 5.3.3-27.el6_5
           Available: php-pdo-5.4.22-1.el6.remi.x86_64 (remi)
               php-pdo(x86-64) = 5.4.22-1.el6.remi
           Available: php-pdo-5.4.23-1.el6.remi.x86_64 (remi)
               php-pdo(x86-64) = 5.4.23-1.el6.remi

因此,我需要找到 php-mysqlnd 5.5 的一些源代码,但显然在 中不可用remi-test。 有什么想法可以找到它吗? 我只想要这个特定的包,所以也许我应该下载它并从源代码构建?

答案1

好吧,我最终通过添加存储库解决了这个问题remi-php55。简而言之,我添加了以下内容/etc/yum.repos.d/remi.repo

[remi-php55]
name=Les RPM de remi de PHP 5.5 pour Enterprise Linux 6 - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/6/php55/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/6/php55/mirror
# WARNING: If you enable this repository, you must also enable "remi"
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

[remi-php55-debuginfo]
name=Les RPM de remi de PHP 5.5 pour Enterprise Linux 6 - $basearch - debuginfo
baseurl=http://rpms.famillecollet.com/enterprise/6/debug-php55/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

然后使用以下命令进行安装:yum install --enablerepo=remi-php55 php-mysqlnd

答案2

您从remi-test存储库安装了 PHP 5.5,但似乎不再启用此存储库。这就是php-mysql建议安装错误的旧版本的原因。请尝试启用remi-test存储库。

yum --enablerepo=remi-test install php-mysql

答案3

看起来remi存储库中的某些软件包不符合您的要求。对于此命令,请尝试禁用该存储库:yum install php-mysql --disablerepo=remi。这应该会让您获得所需的软件包,尽管您将来可能会遇到与 remi 存储库相关的其他问题。

答案4

我的环境与您的略有不同,因为我曾经遇到过这个问题CentOS 7,但是对于Requires: libmysqlclient.so.16(libmysqlclient_16)(64bit)问题它确实起了作用。

我已经安装了MariaDB引擎https://downloads.mariadb.org/mariadb/repositories/#mirror=kisiek我的依赖问题已经消失。

MariaDB从官方存储库安装后,不需要任何额外的工作。

我无法提供更详细的答案,因为我的依赖性问题仅匹配libmysqlclient.so.16(libmysqlclient_16)(64bit)- 我正在安装不同的软件,它们对此提出抱怨。

相关内容