找不到PECL libzip

时间:2018-02-20 16:50:41

标签: php pecl

我试图用pecl安装zipArchive。运行命令后,我收到错误 - "请重新安装libzip发行版"。

我在Amazon Linux 2上运行PHP 7.2。

这是我的输出:

$ ./pecl install zip
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading zip-1.15.2.tgz ...
Starting to download zip-1.15.2.tgz (249,280 bytes)
....................................................done: 249,280 bytes
8 source files, building
running: phpize
Configuring for:
PHP Api Version:         20170718
Zend Module Api No:      20170718
Zend Extension Api No:   320170718
building in /tmp/pear/install/pear-build-ec2-userIZcX1f/zip-1.15.2
running: /tmp/pear/install/zip/configure --with-php-config=/usr/bin/php-config
checking for grep that handles long lines and -e... /usr/bin/grep

...<snip up to warning>...

configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for zip archive read/writesupport... yes, shared
checking libzip... yes
checking PHP version... PHP 7.x
checking for pkg-config... /usr/bin/pkg-config
checking for libzip... not found
configure: error: Please reinstall the libzip distribution
ERROR: `/tmp/pear/install/zip/configure --with-php-config=/usr/bin/php-config' failed

但是如果我检查它已经安装了libzip:

$ sudo yum install libzip
Loaded plugins: langpacks, priorities, update-motd
amzn2-core                                                                                                                                     | 2.0 kB  00:00:00     
Package libzip-0.10.1-8.amzn2.x86_64 already installed and latest version
Nothing to do

我使用./pecl,因为我必须从我的主目录安装新版本的pear,旧版本仍在路径中。这是我用来获取pear的更新版本的命令。

$ wget http://pear.php.net/go-pear.phar
$ php go-pear.phar

我不知道这有什么不同吗?我确实有我的php.ini中提到的正确版本:

;***** Added by go-pear
include_path=".:/home/ec2-user/pear/share/pear"
;*****

任何帮助表示感谢。

1 个答案:

答案 0 :(得分:3)

我已经成功编制了PECL拉链(部分原因是因为英国的雪取消了我预订的一天!)。我没有在php中测试过这个,但它正确加载到phpinfo();

选项1:更新Libzip&amp;希望最好的

我使用了外部CentOS-7 repo(amzn linux 2应该与之相当)以及以下脚本:

#PECL requires libzip 11 - get it from a foreign repo
sudo rpm --import http://wiki.psychotic.ninja/RPM-GPG-KEY-psychotic
#this looks wrong but the repo uses a single release
sudo rpm -ivh http://packages.psychotic.ninja/6/base/i386/RPMS/psychotic-release-1.0.0-1.el6.psychotic.noarch.rpm

#YUM REPO HACKS START
#unfortunately amazon-linux-2 release numbering breaks it - force RHEL 7 numbering
sudo sed -i s/\$releasever/7/g /etc/yum.repos.d/psychotic.repo
#Need to exclude outdated amzn zip packages
sudo yum remove libzip libzip-devel
#check for an exclude line, add our one if not present (to the main repo)
grep -A 100 -m1 "\[amzn2-core" /etc/yum.repos.d/amzn2-core.repo | grep exclude= || sudo sed -i -E "s/($(grep -A 100 -m1 "\[amzn2-core" /etc/yum.repos.d/amzn2-core.repo | grep -m1 ^name=)$)/\1\nexclude=libzip libzip-devel/" /etc/yum.repos.d/amzn2-core.repo
#check this worked, if not modify the existing exclude line(s)
grep -A 100 -m1 "\[amzn2-core" /etc/yum.repos.d/amzn2-core.repo | grep "exclude=.*libzip" || sudo sed -i -E "s/exclude=/exclude=libzip libzip-devel /" /etc/yum.repos.d/amzn2-core.repo
#YUM REPO HACKS END

sudo yum install --enablerepo=psychotic-plus gcc libzip libzip-devel
#now install PECL
wget http://pear.php.net/go-pear.phar
sudo php go-pear.phar
#patch it to cope with the XML being a module
sudo sed -i "$ s|\-n||g" /usr/bin/pecl
#and this should now work
sudo pecl install zip
#may still need to manually add to the php.ini
grep "^extension=zip.so" /etc/php.ini || echo "extension=zip.so" | sudo tee -a /etc/php.ini

要非常小心这个标记为'YUM REPO HACKS'的脚本 - 它有意包含修改repo配置的命令,这些命令进行了最少的测试。它实际上正在做的是用'7'替换pyschotic repo中的'$ releasever'变量,并将'exclude = libzip libzip-devel'添加到amzn2-core repo。你可以用vim做到这一点!

选项2:2个版本的libzip

从我的研究中得知:如果你对服务器上的“谷歌搜索”回购不满意(我不会责怪你,取决于用例)那么你可以将amzn zip留在原地,使用他们的source repo安装libzip 11.2源代码,将其(和/或其库)安装到备用位置(在其他地方找到相关说明)并手动编译php模块。

手动编译zip:

$ pecl download zip
$ tar -xf zip-*.tgz && cd zip-* && phpize
$ ./configure --with-libzip=/path/to/secondary/libzip

...等