PHP 7.4.33添加Zip扩展

一、PHP简介

PHP是一种创建动态交互性站点的强有力的服务器端脚本语言。PHP是目前动态网页开发中使用最为广泛的语言之一。PHP能运行在包括Windows、Linux等在内的绝大多数操作系统环境中。

PHP是免费的,并且使用非常广泛。同时,对于像微软ASP这样的竞争者来说,PHP无疑是另一种高效率的选项。

二、安装Libzip

1、下载Libip软件包

[root@localhost ~]# wget -c https://libzip.org/download/libzip-1.2.0.tar.gz

2、解压

[root@localhost ~]# tar xf libzip-1.2.0.tar.gz

3、编译及安装

[root@localhost ~]# cd libzip-1.2.0

[root@localhost libzip-1.2.0]# ./configure

[root@localhost libzip-1.2.0]# make && make install

PHP 7.4.33添加Zip扩展

三、添加Zip扩展(源码编译)

1、下载Zip软件包

[root@localhost ~]# wget -c https://pecl.php.net/get/zip-1.21.0.tgz

2、解压

[root@localhost ~]# tar xf zip-1.21.0.tgz

3、生成configure

[root@localhost ~]# cd zip-1.21.0

# 注意:phpize安装位置可通过此命令查找:find / -name “phpize”

[root@localhost zip-1.21.0]# /usr/bin/phpize

Configuring for:

PHP Api Version:              20190902

Zend Module Api No:        20190902

Zend Extension Api No:    320190902

# 注意:php-config安装位置可通过此命令查找:find / -name “php-config”

[root@localhost zip-1.21.0]# ./configure

[root@localhost zip-1.21.0]# make && make install

# 注意:如果make报错(/usr/local/include/zip.h:59:21: fatal error: zipconf.h: No such file or directory)再执行以下命令

[root@localhost zip-1.21.0]# ln -sf /usr/local/lib/libzip/include/zipconf.h /usr/local/include

4、查看是否生成zip.so

[root@localhost zip-1.21.0]# ll /opt/remi/php74/root/usr/lib64/php/modules/zip.so

-rwxr-xr-x 1 root root 240656 Mar 15 14:43 /opt/remi/php74/root/usr/lib64/php/modules/zip.so

5、创建zip.ini文件

[root@localhost ~]# cd /etc/opt/remi/php74/php.d

[root@localhost php.d]# vim zip.ini

;Enable zip extension module
extension=zip.so

6、重启php-fpm

[root@localhost php.d]# systemctl restart php74-php-fpm

7、查看测试页是否成功加载zip模块

PHP 7.4.33添加Zip扩展

四、添加Zip扩展(Yum安装)

1、安装Zip

[root@localhost ~]# yum -y install php74-php-zip

PHP 7.4.33添加Zip扩展

2、查看是否生成zip.so及30-zip.ini

[root@localhost ~]# ll /opt/remi/php74/root/usr/lib64/php/modules/zip.so

-rwxr-xr-x 1 root root 79536 Sep 16 14:28 /opt/remi/php74/root/usr/lib64/php/modules/zip.so

[root@localhost ~]# ll /etc/opt/remi/php74/php.d/30-zip.ini

-rw-r–r– 1 root root 47 Sep 16 14:28 /etc/opt/remi/php74/php.d/30-zip.ini

[root@localhost ~]# cat /etc/opt/remi/php74/php.d/30-zip.ini

; Enable ZIP extension module

extension=zip.so

3、重启php-fpm

[root@localhost php.d]# systemctl restart php74-php-fpm

4、查看测试页是否成功加载zip模块

PHP 7.4.33添加Zip扩展

原创文章,作者:admin,如若转载,请注明出处:https://hostingchat.cn/4789.html

(0)
admin的头像admin
上一篇 2023年3月14日 上午12:00
下一篇 2023年3月15日 下午4:50

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

QQ
分享本页
返回顶部