如何使用 CentOS 7 在 PHP 7.2 上安装 zipArchive?

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

How can I install zipArchive on PHP 7.2 with CentOS 7?

php

提问by STINGRAY

I am trying to install ziparchive and domdocument on nginx web server that has the latest WordPress. In order to run Avada theme, I need these two on the local CentOS 7 test server. I am searching for an answer for the past 3 days. What shoud I do?

我正在尝试在具有最新 WordPress 的 nginx Web 服务器上安装 ziparchive 和 domdocument。为了运行 Avada 主题,我需要在本地 CentOS 7 测试服务器上使用这两个。我正在寻找过去 3 天的答案。我该怎么办?

Here is a partial list of "yum list installed:"

这是“已安装 yum 列表”的部分列表:

php-common.x86_64                   7.2.3-2.el7.remi               @remi-php72<BR>
php-fpm.x86_64                      7.2.3-2.el7.remi               @remi-php72<BR>
php-json.x86_64                     7.2.3-2.el7.remi               @remi-php72<BR>
php-mysqlnd.x86_64                  7.2.3-2.el7.remi               @remi-php72<BR>
php-pdo.x86_64                      7.2.3-2.el7.remi               @remi-php72<BR>
php72.x86_64                        1.0-1.el7.remi                 @remi-safe<BR>
php72-php-cli.x86_64                7.2.3-2.el7.remi               @remi-safe<BR>
php72-php-common.x86_64             7.2.3-2.el7.remi               @remi-safe<BR>
php72-php-json.x86_64               7.2.3-2.el7.remi               @remi-safe<BR>
php72-php-mbstring.x86_64           7.2.3-2.el7.remi               @remi-safe<BR>
php72-php-pear.noarch               1:1.10.5-6.el7.remi            @remi-safe<BR>
php72-php-process.x86_64            7.2.3-2.el7.remi               @remi-safe<BR>
php72-php-xml.x86_64                7.2.3-2.el7.remi               @remi-safe<BR>
php72-runtime.x86_64                1.0-1.el7.remi                 @remi-safe<BR>

unzip.x86_64                        6.0-16.el7                     @base<BR>

回答by Remi Collet

php-json.x86_64 7.2.3-2.el7.remi @remi-php72

php72-php-json.x86_64 7.2.3-2.el7.remi @remi-safe

php-json.x86_64 7.2.3-2.el7.remi @remi-php72

php72-php-json.x86_64 7.2.3-2.el7.remi @remi-safe

Looks like your installation is a mess, you have installed half of the php-packages (base packages) and half of the php72-php-(SCL packages)

看起来你的安装很乱,你已经安装了一半的php-包(基础包)和一半的php72-php-(SCL 包)

Read the FAQ about Difference between php-* and php##-php-* packages ?

阅读有关php-* 和 php##-php-* 包之间区别的常见问题解答

php-fpm.x86_64 7.2.3-2.el7.remi @remi-php72

php-fpm.x86_64 7.2.3-2.el7.remi @remi-php72

As you are using FPM as base package from remi-php72, you need zip extension from the same repository (which is probably not enabled, chech with yum repolist)

当您使用 FPM 作为remi-php72 的基本包时,您需要来自同一存储库的 zip 扩展(可能未启用,请检查yum repolist

Drop the unneeded packages

丢弃不需要的包

yum remove php72\*

As explained by the wizard, enable the repository permanently to ensure all extensions will be pulled from it

正如向导所解释的,永久启用存储库以确保将从中提取所有扩展。

yum-config-manager --enable remi-php72
yum install php-pecl-zip

echo "extension=zip.so" >> /etc/php.d/zip.in

echo "extension=zip.so" >> /etc/php.d/zip.in

Never do this, each package provides its configuration file to enable the provided extension.

永远不要这样做,每个包都提供了它的配置文件来启用提供的扩展。

回答by tringuyen

try yum search zip |grep -i phpand install with package name came back

尝试yum search zip |grep -i php使用包名安装回来了

回答by tringuyen

You can try: yum install php-pecl-zip.x86_64

你可以试试: yum install php-pecl-zip.x86_64

Try installing that and enabling it by running: echo "extension=zip.so" >> /etc/php.d/zip.ini

尝试安装它并通过运行启用它: echo "extension=zip.so" >> /etc/php.d/zip.ini

回答by Banana

I was able to resolve this issue via the following:

我能够通过以下方式解决这个问题:

yum install yum-utils
wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum install remi-release-7.rpm
yum-config-manager --enable remi-php72
yum install php72-php-pecl-zip
echo "extension=/opt/remi/php72/root/usr/lib64/php/modules/zip.so" >> /etc/php.d/zip.ini

The issue was due to using the remi repo which doesn't place the module in one of the default locations PHP expects. Setting the absolute path to zip.so in the extension variable under /etc/php.d/zip.ini fixes the issue.

问题是由于使用 remi repo,它没有将模块放置在 PHP 期望的默认位置之一。在 /etc/php.d/zip.ini 下的扩展变量中设置 zip.so 的绝对路径可解决此问题。

You can find the location of zip.so on your system via the following if the above path doesn't work:

如果上述路径不起作用,您可以通过以下方式在您的系统上找到 zip.so 的位置:

updatedb
locate zip.so

回答by Imad Oulhou

This method works for me: First type: yum search zip |grep -i phpthen it will appear you all modules related to ZIP extensions with various of PHP version like so:

这种方法对我有用:首先输入:yum search zip |grep -i php然后它会出现与各种 PHP 版本的 ZIP 扩展相关的所有模块,如下所示:

ea-php54-php-zip.x86_64 : A module for PHP applications that need to handle .zip
ea-php55-php-zip.x86_64 : A module for PHP applications that need to handle .zip
ea-php56-php-zip.x86_64 : A module for PHP applications that need to handle .zip
ea-php70-php-zip.x86_64 : A module for PHP applications that need to handle .zip
ea-php71-php-zip.x86_64 : A module for PHP applications that need to handle .zip
ea-php72-php-zip.x86_64 : A module for PHP applications that need to handle .zip
ea-php73-php-zip.x86_64 : A module for PHP applications that need to handle .zip

select whatever version you working with by: yum install ea-php72-php-zip.x86_64finally, restart the Apache through service httpd restart

选择您使用的任何版本:yum install ea-php72-php-zip.x86_64最后,通过以下方式重新启动 Apacheservice httpd restart