首页 > 解决方案 > 为通过 Remi 的存储库安装的 PHP 安装 php-opcache

问题描述

我有一个具有以下设置的环境:

我已经像这样设置了安装的php:

sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf -y install http://rpms.remirepo.net/enterprise/remi-release-8.rpm 

sudo dnf -y install php74 php74-php-common php74-php-devel php74-php-cli php74-php-fpm

现在我想安装 php-opcache。但是 dnf 报告说似乎没有 module php74-php-opcache

$ sudo dnf install php74-php-opcache

Updating Subscription Management repositories.
Last metadata expiration check: 0:56:51 ago on Fri 04 Jun 2021 13:52:35 NZST.
No match for argument: php74-php-opcache
Error: Unable to find a match: php74-php-opcache

我相当确信这与 repos 的设置方式有关,就像在我的开发环境中一样,它可以工作。

$ sudo dnf -y install php74-php-opcache
Last metadata expiration check: 0:11:18 ago on Fri 04 Jun 2021 02:36:41 PM NZST.
Dependencies resolved.
==================================================================================================================================================================================================================================
 Package                                                    Architecture                                    Version                                                      Repository                                          Size
==================================================================================================================================================================================================================================
Installing:
 php74-php-opcache                                          x86_64                                          7.4.20-1.el8.remi                                            remi-safe                                          274 k

这是dnf repolist问题环境的输出:

$ sudo dnf repolist
Updating Subscription Management repositories.
repo id                                                                                                repo name
epel                                                                                                   Extra Packages for Enterprise Linux 8 - x86_64
epel-modular                                                                                           Extra Packages for Enterprise Linux Modular 8 - x86_64
mod-pagespeed                                                                                          mod-pagespeed
pgdg-common                                                                                            PostgreSQL common RPMs for RHEL/CentOS 8 - x86_64
pgdg12                                                                                                 PostgreSQL 12 for RHEL/CentOS 8 - x86_64
remi-modular                                                                                           Remi's Modular repository for Enterprise Linux 8 - x86_64
rhel-8-for-x86_64-appstream-rpms                                                                       Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)
rhel-8-for-x86_64-baseos-rpms                                                                          Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)

作为旁注,我尝试过dnf install php-opcache. 发现这很好。但它会下载 7.2 版并将 opcache.so 放在与 PHP 寻找模块的位置不同的位置,并且没有 10-opcache.ini 文件。我确实尝试手动将这些文件复制到此 PHP 安装正在查找这些文件的位置,但我收到了警告

/opt/remi/php74/root/usr/lib64/php/modules/opcache.so: undefined symbol: _zval_ptr_dtor

标签: phpphp-7opcache

解决方案


显然,从粘贴的 repolist 中,“remi”存储库未启用。

要进行正确配置,请按照向导说明进行操作


推荐阅读