CentOS 7编译安装PHP 7.4提示No package 'libzip' found或者(libzip >= 0.11)

CentOS 7编译安装PHP 7.4提示No package ‘libzip’ found或者(libzip >= 0.11)

错误日志:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
checking for zip archive read/write support... yes
checking for libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0... no
configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:

No package 'libzip' found
No package 'libzip' found
No package 'libzip' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBZIP_CFLAGS
and LIBZIP_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

原因分析:CentOS 7上自带或通过yum安装的libzip版本过低

解决方法

(1)查看是否有安装过libzip

1
2
rpm -q libzip
rpm -q libzip-devel

如果有,卸载它

1
yum remove libzip-devel libzip

(2)然后从官网下载并编译安装

编译安装PHP 7.4提示No package ‘libzip’ found或者(libzip >= 0.11),原因是libzip没有安装或者版本太低,解决方法如下:

1
2
3
4
5
6
7
8
#卸载旧版本的libzip
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
./configure
make && make install

安装完成后,查看是否存在/usr/local/lib/pkgconfig目录,如果存在,执行如下命令来设置PKG_CONFIG_PATH:

1
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/"
1
2
# whereis libzip
libzip: /usr/local/lib/libzip.la /usr/local/lib/libzip.a /usr/local/lib/libzip.so