如何在 php 7.4 上安装 ziparchive?

Posted

技术标签:

【中文标题】如何在 php 7.4 上安装 ziparchive?【英文标题】:How can I install ziparchive on php 7.4? 【发布时间】:2020-05-22 07:59:23 【问题描述】:

我在 centos 7 上运行 Virtuamin,我无法在 php 7.4 上安装 ziparchive,但是当我切换到 php 7.2 时,它可以工作。我需要 php 7.4 才能工作,因为它更快,而 wordpress 脚本需要 7.3+ 才能有效工作。

【问题讨论】:

【参考方案1】:
sudo apt-get install php7.4-zip

这适用于 ubuntu 18.04

【讨论】:

【参考方案2】:

我使用的是 Debian 9,它不附带 PHP7.4,但如果您从 Sury 添加存储库,它可以安装。

sudo apt install ca-certificates apt-transport-https
wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list

在那之后,我成功地运行了这个:

apt install php7.4-zip
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  php7.4-zip
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 20.5 kB of archives.
After this operation, 94.2 kB of additional disk space will be used.
Get:1 https://packages.sury.org/php stretch/main amd64 php7.4-zip amd64 7.4.7-1+                                                                           0~20200612.18+debian9~1.gbp671911 [20.5 kB]
Fetched 20.5 kB in 0s (149 kB/s)
Selecting previously unselected package php7.4-zip.
(Reading database ... 107553 files and directories currently installed.)
Preparing to unpack .../php7.4-zip_7.4.7-1+0~20200612.18+debian9~1.gbp671911_amd                                                                           64.deb ...
Unpacking php7.4-zip (7.4.7-1+0~20200612.18+debian9~1.gbp671911) ...
Processing triggers for libapache2-mod-php7.4 (7.4.7-1+0~20200612.18+debian9~1.g                                                                           bp671911) ...
Setting up php7.4-zip (7.4.7-1+0~20200612.18+debian9~1.gbp671911) ...
Creating config file /etc/php/7.4/mods-available/zip.ini with new version
Processing triggers for php7.4-fpm (7.4.7-1+0~20200612.18+debian9~1.gbp671911) .                                                                           ..
NOTICE: Not enabling PHP 7.4 FPM by default.
NOTICE: To enable PHP 7.4 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php7.4-fpm
NOTICE: You are seeing this message because you have apache2 package installed.
Processing triggers for libapache2-mod-php7.4 (7.4.7-1+0~20200612.18+debian9~1.g                                                                           bp671911) ...
Processing triggers for php7.4-cgi (7.4.7-1+0~20200612.18+debian9~1.gbp671911) .                                                                           ..
Processing triggers for php7.4-cli (7.4.7-1+0~20200612.18+debian9~1.gbp671911) .                                                                           ..

【讨论】:

【参考方案3】:

也许你想看看这篇文章: https://www.cloudbooklet.com/upgrade-php-version-to-php-7-4-on-ubuntu/

基本上,它会告诉您:

为 PHP 7.4 添加 PPA 添加具有 PHP 7.4 包和其他所需 PHP 扩展的 ondrej/php。

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update

然后就可以安装扩展了

sudo apt install php7.4-zip

或者安装所有常用的:

sudo apt install php7.4-common php7.4-mysql php7.4-xml php7.4-xmlrpc php7.4-curl php7.4-gd php7.4-imagick php7.4-cli php7.4-dev php7.4-imap php7.4-mbstring php7.4-opcache php7.4-soap php7.4-zip php7.4-intl -y

【讨论】:

【参考方案4】:

这就是我在我的 ubuntu 上安装它的方式:-

对于 PHP

sudo apt-get install php7.0-zip

Centos

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

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

注意:安装以上内容后请务必重启服务器

sudo /etc/init.d/apache2 restart or sudo service nginx restart

【讨论】:

我运行的是 centos 而不是 ubuntu,已经为 php 7.2 安装了 ziparchive,我需要它才能在 php 7.4 上运行。

以上是关于如何在 php 7.4 上安装 ziparchive?的主要内容,如果未能解决你的问题,请参考以下文章

Docker:如何安装 PHP 7.4 扩展 ext-http?

Composer-1.5.5在CentOS-7.4上不能与php-7.2一起使用

如何在 RHEL 7.4 上安装 cloudstack

Linux安装Nginx1.7.4php5.5.15和配置

如何在“Red Hat Enterprise Linux 7.4”上安装 libyaml-devel

宝塔面板php7.3&7.4版本不支持ZipArchive手工安装扩展方法