PHP 在 PHP.ini 中启用 bz2 扩展

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

PHP Enable bz2 Extension In Php.ini

phpcomposer-phpphp-inibzip2

提问by Alex Pelletier

I an trying to download a file using composer in php, but the file needs to be decompress with bzipped. Here is the error I get:

我试图在 php 中使用 composer 下载一个文件,但该文件需要用 bzip 解压。这是我得到的错误:

[UnexpectedValueException]                                                   
unable to decompress bzipped phar archive "/home/admin/public_html/subdo  
mains/testing4/vendor/jakoch/phantomjs/da2db411008833dfaa24e92e129aa037.bz2  
" to temporary file, enable bz2 extension in php.ini   

In my php.ini file I have added:

在我的 php.ini 文件中,我添加了:

extension = "bz2.so" 

After adding that I still get the error when I try and install the file.

添加后,当我尝试安装文件时仍然出现错误。

When I run infophp(-1) I get:

当我运行 infophp(-1) 时,我得到:

bzip2 compression   disabled (install pecl/bz2)

Do I need to enable bzip2? If so how do I do it. Am I doing something wrong with allowing the extension?

我需要启用 bzip2 吗?如果是这样,我该怎么做。我在允许扩展时做错了什么吗?

回答by Viraths

You can install this as php extension easily.

您可以轻松地将其安装为 php 扩展。

apt-get install php5.6-bz2
  • php(yourversion)-bz2
  • php(你的版本)-bz2

Source

来源

回答by Ma'moon Al-Akash

Enabling an extention in PHP is not only by including it into php.inifile, you need to recompile your PHP installation with package support being enabled, in order to do this for bz2, you have to execute the needed pecl command:

在 PHP 中启用扩展不仅是通过将其包含到php.ini文件中,您还需要在启用包支持的情况下重新编译 PHP 安装,为了对 bz2 执行此操作,您必须执行所需的 pecl 命令:

pecl install bz2

To install peclyou have to install pearand phpize, on a debian based system, the following command should be sufficint:

要安装,pecl您必须在基于 debian 的系统上安装pearphpize,以下命令就足够了:

apt-get install php5-dev php-pear

Finally you need to add the new extension to php.inifile, Don't forget to reload your web server after that.

最后,您需要将新扩展名添加到php.ini文件中,之后不要忘记重新加载您的 Web 服务器。

HTH

HTH