在部署易优CMS后,后台提示"Zip支持:NO,请开启php.ini中的php-zip拓展"
zip包各个版本下载地址:http://pecl.php.net/package/zip
在这里我选择1.15.4版本的zip包
wget http://pecl.php.net/get/zip-1.15.4.tgz
tar xf zip-1.15.4.tgz
cd zip-1.15.4
接下来执行phpize
命令,该命令在PHP安装的目录的bin文件下里面
/www/server/php/73/bin/phpize
Configuring for:
PHP Api Version: 20180731
Zend Module Api No: 20180731
Zend Extension Api No: 320180731
接下来配置zip
./configure
直接执行会提示configure: error: Cannot find php-config. Please use --with-php-config=PATH
先找出php-config
文件在哪里,然后在执行时加上--with-php-config=PATH
find / --name php-config
/www/server/php/73/bin/php-config
./configure --with-php-config=/www/server/php/73/bin/php-config
提示configure: error: Please reinstall the libzip distribution
,这个错误的含义是没有找到libzip
,请重新安装libzip
这个软件包
先尝试卸载这个包
yum remove -y libzip
Loaded plugins: fastestmirror
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository plus is listed more than once in the configuration
No Match for argument: libzip
No Packages marked for removal
说明服务器并没有安装libzip
这个软件包
下载libzip
,官网是:https://libzip.org/download/
cd ~
wget https://libzip.org/download/libzip-1.5.2.tar.gz
tar xf libzip-1.5.2.tar.gz
cd libzip-1.5.2
接下来编译安装libzip
mkdir build
cd build
cmake ..
错误提示:
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版本是2.8.12.2不满足他所需要的3.0.2
安装新版的cmake,先下载包
cd ~
wget https://cmake.org/files/v3.6/cmake-3.6.2.tar.gz
tar xf cmake-3.6.2.tar.gz
cd cmake-3.6.2
编译安装
./bootstrap
gmake && gmake install
编译安装完成后,卸载原来的cmake,再添加个软连接,最后继续安装libzip
yum remove -y cmake
ln -s /usr/local/bin/cmake /usr/bin/
# 查看cmake的版本
cmake --version
# 继续安装libzip
cd ~/libzip-1.5.2/build
cmake ..
make && make install
执行上面的安装zip模块的步骤
cd ~/zip-1.15.4
./configure --with-php-config=/www/server/php/73/bin/php-config
make && make install
# zip拓展就添加在这个目录下面了
Installing shared extensions: /www/server/php/73/lib/php/extensions/no-debug-non-zts-20180731/
修改php.ini
文件,添加zip模块
vim /www/server/php/73/etc/php.ini
# 配置文件添加这句
extension=zip
重启php-fpm,出现以下错误
Gracefully shutting down php-fpm done
Starting php-fpm [05-Sep-2019 12:29:57] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library '/www/server/php/73/lib/php/extensions/no-debug-non-zts-20180731/zip' (tried: /www/server/php/73/lib/php/extensions/no-debug-non-zts-20180731/zip (/www/server/php/73/lib/php/extensions/no-debug-non-zts-20180731/zip: cannot open shared object file: No such file or directory), /www/server/php/73/lib/php/extensions/no-debug-non-zts-20180731//www/server/php/73/lib/php/extensions/no-debug-non-zts-20180731/zip.so (/www/server/php/73/lib/php/extensions/no-debug-non-zts-20180731//www/server/php/73/lib/php/extensions/no-debug-non-zts-20180731/zip.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
done
解决方式如下:
把zip.so分别做个软链接到lib和lib64
ln -s /www/server/php/73/lib/php/extensions/no-debug-non-zts-20180731/zip.so /usr/lib/zip.so
ln -s /www/server/php/73/lib/php/extensions/no-debug-non-zts-20180731/zip.so /usr/lib64/zip.so
#使他们生效
ldconfig /usr/local/lib
ldconfig /usr/local/lib64
重启php-fpm
/etc/init.d/php-fpm-73 restart
Gracefully shutting down php-fpm done
Starting php-fpm done
查看模块是否添加成功
php -m | grep zip
zip
php添加zip模块成功,最后删除下载的安装包及其目录
rm -rf cmake-3.6.2 cmake-3.6.2.tar.gz libzip-1.5.2 libzip-1.5.2.tar.gz zip-1.15.4 zip-1.15.4.tgz