我正在尝试用pecl安装zipArchive。运行该命令后,我得到一个错误--“请重新安装libzip发行版”。
我在Amazon 2上运行PHP7.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"
;*****任何帮助都很感激。
发布于 2018-02-27 11:37:15
我已经成功地编译了PECL zip (部分原因是英国下雪取消了我预定的一天!)我还没有在php中测试这一点,但是它正确地加载到phpinfo()中;
选项1:更新Libzip &希望获得最好的
我使用了外部CentOS-7repo( amzn 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‘的代码非常小心--它故意包含一些命令来修改您的回购配置,这些配置已经进行了最少的测试。实际上,它所做的只是用'7‘替换了'$releasever’变量,并在amzn2 2核心回购中添加了'exclude=libzip libzip-devel‘。你可以用维姆做这件事!
选项2: libzip的2个版本
从我的研究来看:如果你对服务器上的“被谷歌发现”的回购感到不舒服(我不怪你,取决于用例),那么你可以离开amzn zip,使用它们的源代码回购安装libzip 11.2源代码,将它(和/或它的库)安装到另一个位置(在其他地方查找说明),并手动编译php模块。
要手动编译zip:
$ pecl download zip
$ tar -xf zip-*.tgz && cd zip-* && phpize
$ ./configure --with-libzip=/path/to/secondary/libzip...etc
https://stackoverflow.com/questions/48890287
复制相似问题