PHP 错误:“zip 扩展名和解压缩命令都丢失,正在跳过。”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41274829/
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
PHP error: "The zip extension and unzip command are both missing, skipping."
提问by b85411
When I run a composer update
I get this error message:
当我运行 a 时,composer update
我收到此错误消息:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Failed to download psr/log from dist: The zip extension and unzip command are both missing, skipping.
The php.ini used by your command-line PHP is: /etc/php/7.0/cli/php.ini
Now trying to download from source
What do I need to do to enable the zip and unzip commands so that composer can download dependencies?
我需要做什么来启用 zip 和 unzip 命令,以便 composer 可以下载依赖项?
回答by Arrisar
Depending on your flavour of Linux and PHP version these may vary.
根据您的 Linux 风格和 PHP 版本,这些可能会有所不同。
(sudo) yum install zip unzip php-zip
(sudo) apt install zip unzip php-zip
This is a very commonly asked question, you'll be able to find more useful info in the aether by searching <distro> php <version> zip extension
.
这是一个非常常见的问题,您可以通过搜索在以太中找到更多有用的信息<distro> php <version> zip extension
。
回答by Olawale
For servers with PHP 5.6
适用于 PHP 5.6 的服务器
sudo apt-get install zip unzip php5.6-zip
回答by Peter Breuls
For Debian Jessie (which is the current default for the PHP image on Docker Hub):
对于 Debian Jessie(这是 Docker Hub 上 PHP 映像的当前默认值):
apt-get install --yes zip unzip php-pclzip
You can omit the --yes, but it's useful when you're RUN-ing it in a Dockerfile.
您可以省略 --yes,但是当您在 Dockerfile 中运行它时它很有用。
回答by Goke Obasa
For older Ubuntu distros i.e 16.04, 14.04, 12.04 etc
对于较旧的 Ubuntu 发行版,即 16.04、14.04、12.04 等
sudo apt-get install zip unzip php7.0-zip
回答by Aqib Ashef
I had PHP7.2 on a Ubuntu 16.04 server and it solved my problem:
我在 Ubuntu 16.04 服务器上安装了 PHP7.2,它解决了我的问题:
sudo apt-get install zip unzip php-zip
sudo apt-get install zip unzip php-zip
Update
更新
Tried this for Ubuntu 18.04 and worked as well.
为 Ubuntu 18.04 尝试了这个并且工作得很好。
回答by Oscar David
I'm Using Ubuntu and with the following command worked
我正在使用 Ubuntu 并使用以下命令工作
apt-get install --yes zip unzip
apt-get install --yes zip unzip
回答by aphoe
If you are using Ubuntu and PHP 7.2, use this...
如果您使用的是Ubuntu 和 PHP 7.2,请使用此...
sudo apt-get update
sudo apt-get install zip unzip php7.2-zip
回答by Joyal
I got this error when I installed Laravel 5.5 on my digitalocean cloud server (Ubuntu 18.04 and PHP 7.2) and the following command fixed it.
当我在我的 digitalocean 云服务器(Ubuntu 18.04 和 PHP 7.2)上安装 Laravel 5.5 时出现此错误,并且以下命令修复了它。
sudo apt install zip unzip php7.2-zip
sudo apt install zip unzip php7.2-zip
回答by DJ Sipe
Not to belabor the point, but if you are working in a Dockerfile
, you would solve this particular issue with Composer by installing the unzip
utility. Below is an example using the official PHP imageto install unzip
and the zip
PHP extension for good measure.
不是要强调这一点,但如果您在 . 中工作Dockerfile
,您可以通过安装该unzip
实用程序来解决 Composer 的这个特定问题。下面是一个使用官方 PHP 映像安装unzip
和zip
PHP 扩展的示例。
FROM php:7.4-apache
# Install Composer
COPY --from=composer /usr/bin/composer /usr/bin/composer
# Install unzip utility and libs needed by zip PHP extension
RUN apt-get update && apt-get install -y \
zlib1g-dev \
libzip-dev \
unzip
RUN docker-php-ext-install zip
This is a helpful GitHub issuewhere the above is lovingly lifted from.
这是一个有用的 GitHub 问题,上面的内容被亲切地摘录了。
回答by Armel Larcier
On docker with image php:7.2-apache
I just needed zip and unzip. No need for php-zip :
在带有图像的 docker 上,php:7.2-apache
我只需要压缩和解压缩。不需要 php-zip :
apt-get install zip unzip
apt-get install zip unzip
or Dockerfile
或 Dockerfile
RUN ["apt-get", "update"]
RUN ["apt-get", "install", "-y", "zip"]
RUN ["apt-get", "install", "-y", "unzip"]