【安装A:从 PHP 代码包编译】
下载 php 源码包并解压:
1 | wget http: //php .net /distributions/php-7 .3.13. tar .xz && tar -xvf php-7.3.13. tar .xz && cd php-7.3.13 |
进入php源程序目录中的ext目录中,这里存放着各个扩展模块的源代码,选择imap模块。
1 2 3 | cd ext /zip && /usr/local/php/bin/phpize . /configure --with-zip --with-php-config= /usr/local/php/bin/php-config make && make install |
输出:
1 | Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20180731/ |
在 php.ini 文件中添加:
1 2 | ; [zip] extension = "zip.so" |
然后重启Apache即可加载。
验证:
1 | php -m |
【安装B:使用源码编译安装zip】
下载:http://pecl.php.net/package/zip
参考:http://www.uedbox.com/centos7-ziparchive-libzip/
1 2 3 4 | wget http: //pecl .php.net /get/zip-1 .14.0.tgz && tar zxvf zip-1.14.0.tgz && cd zip-1.14.0 /usr/local/php/bin/phpize . /configure --with-php-config= /usr/local/php/bin/php-config --with-libzip= /usr/local/lib64/ make && make install |
生成的模块路径:
1 | /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/zip .so |
【安装C:使用PECL安装zip】
参考:https://answers.launchpad.net/ubuntu/+question/125672
1 | pecl install zip |
输出:
1 2 3 4 5 6 | ... Build process completed successfully Installing '/usr/local/php/lib/php/extensions/no-debug-zts-20121212/zip.so' install ok: channel: //pecl .php.net /zip-1 .13.2 configuration option "php_ini" is not set to php.ini location You should add "extension=zip.so" to php.ini |
如果报错:
1 2 3 4 5 | ... running: phpize Can't find PHP headers in /usr/include/php The php-devel package is required for use of this command . ERROR: `phpize' failed |
安装:
1 | yum install php-devel |