您的位置:首页 > 技术中心 > PHP教程 >

Centos7下php7如何安装zip扩展

时间:2022-02-23 17:40

本篇文章给大家介绍一下Centos7下php7安装zip扩展的方法。有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助。

安装:

yum install -y php-devel #用于编译
cd /usr/local/src
wget http://pecl.php.net/get/zip-1.15.3.tgz  
tar -zxvf zip-1.15.3.tgz

cd zip-1.15.3  
phpize
whereis php-config
./configure --with-php-config=/usr/bin/php-config

报错:configure: error: Please reinstall the libzip distribution

最新版本请参考官网:https://nih.at/libzip/ ,libzip 需要 cmake 。

yum install -y cmake
cd ../
yum remove libzip
wget https://libzip.org/download/libzip-1.2.0.tar.gz
tar -zxvf libzip-1.2.0.tar.gz
cd libzip-1.2.0.tar.gz
mkdir build && cd build && /usr/local/bin/cmake .. && make && make install

又报错:

CMake Error at CMakeLists.txt:4 (CMAKE_MINIMUM_REQUIRED):
  CMake 3.0.2 or higher is required.  You are running version 2.8.12.2
-- Configuring incomplete, errors occurred!

cmake版本过低,需新版本。

yum remove cmake
yum install -y cmake3
cmake -version

OK,cmake环境版本升级完毕。

然后再编译 zip 。

cd ../zip-1.15.3
./configure --with-php-config=/usr/bin/php-config
make
make install

安装过程中若出现

fatal error: zipconf.h: No such file or directory

使用命令:

find /usr/local -iname 'zipconf.h'
ln -s /usr/local/lib/libzip/include/zipconf.h /usr/local/include

然后再执行一遍安装即可。最后用命令查看有没有zip.so文件。

ls  /usr/lib64/php/modules/

修改 /etc/php.ini :

zlib.output_compression = On
extension=/usr/lib64/php/modules/zip.so

重启 apache:

service httpd restart

再查看 phpinfo,就有 zip 扩展了。

zip model

推荐学习:php视频教程

以上就是Centos7下php7如何安装zip扩展的详细内容,更多请关注gxlsystem其它相关文章!

本类排行

今日推荐

热门手游