1、概述

安装前咱们先看下我本地环境

[root@elk php8]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.9 (Maipo)
[root@elk php8]#
[root@elk php8]# ./bin/php -v
PHP 8.1.18 (cli) (built: Apr 17 2023 13:15:17) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.18, Copyright (c) Zend Technologies
[root@elk php8]#

为了避免重复安装,记得先通过 “./bin/php -m ”  确认是否已安装此扩展。

[root@elk php8]# ./bin/php -m
[PHP Modules]
bcmath
calendar
...
...
...

安装这两个扩展的先后顺序:

①、安装zip(ZipArchive),需要先安装libzip扩展
②、安装libzip,需要先安装cmake

下面我就cmake、libzip、zip的先后顺序安装。

2、安装cmake

在安装cmake之前先确认是否已安装,防止重复安装,命令:“cmake --version”

[root@elk wp]# cmake --version
bash: cmake: 未找到命令...
相似命令是: 'make'
[root@elk wp]#

官网地址:CMake

下载命令:“wget  https://github.com/Kitware/CMake/releases/download/v3.26.3/cmake-3.26.3.tar.gz”

[root@elk wp]# ll cmake-3.26.3.tar.gz
-rw-r--r-- 1 root root 10668855 4月  22 19:44 cmake-3.26.3.tar.gz
# 解压
[root@elk wp]# tar -zxvf cmake-3.26.3.tar.gz# 进入解压目录
[root@elk wp]# cd cmake-3.26.3/# 1、执行bootstrap命令
[root@elk cmake-3.26.3]# ./bootstrap
-- Checking for curses support
-- Checking for curses support - Failed
-- Looking for a Fortran compiler
-- Looking for a Fortran compiler - /usr/bin/f95
-- Performing Test run_pic_test
-- Performing Test run_pic_test - Success
-- Performing Test run_inlines_hidden_test
-- Performing Test run_inlines_hidden_test - Success
-- Configuring done (50.0s)
-- Generating done (1.2s)
-- Build files have been written to: /u01/tool/wp/cmake-3.26.3
---------------------------------------------
CMake has bootstrapped.  Now run gmake.# 2、make && make install
-- Installing: /usr/local/share/cmake-3.26/Templates/Windows/StoreLogo.png
-- Installing: /usr/local/share/cmake-3.26/Templates/Windows/Windows_TemporaryKey.pfx
-- Installing: /usr/local/share/vim/vimfiles/indent
-- Installing: /usr/local/share/vim/vimfiles/indent/cmake.vim
-- Installing: /usr/local/share/vim/vimfiles/syntax
-- Installing: /usr/local/share/vim/vimfiles/syntax/cmake.vim
-- Installing: /usr/local/share/emacs/site-lisp/cmake-mode.el
-- Installing: /usr/local/share/aclocal/cmake.m4
-- Installing: /usr/local/share/bash-completion/completions/cmake
-- Installing: /usr/local/share/bash-completion/completions/cpack
-- Installing: /usr/local/share/bash-completion/completions/ctest
[root@elk cmake-3.26.3]#

检查是否安装成功

[root@elk cmake-3.26.3]# cmake --version
cmake version 3.26.3CMake suite maintained and supported by Kitware (kitware.com/cmake).
[root@elk cmake-3.26.3]#

3、安装libzip

官网:libzip

下载:wget -c https://libzip.org/download/libzip-1.9.2.tar.gz
解压并创建构建目录

[root@elk wp]# tar -zvxf libzip-1.9.2.tar.gz
//进入安装包
[root@elk wp]# cd libzip-1.9.2
//创建build目录
[root@elk wp]# mkdir build && cd build[root@elk build]# cmake -DCMAKE_INSTALL_PREFIX=/usr/lib64
CMake Warning:No source or binary directory provided.  Both will be assumed to be thesame as the current working directory, but note that this warning willbecome a fatal error in future CMake releases.CMake Error: The source directory "/u01/tool/wp/libzip-1.9.2/build" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.// cmake 上级目录
[root@elk build]# cmake ..
-- Looking for getopt
-- Looking for getopt - found
-- Found Perl: /usr/bin/perl (found version "5.16.3")
-- Configuring done (6.5s)
-- Generating done (0.2s)
-- Build files have been written to: /u01/tool/wp/libzip-1.9.2/build//编译并安装
[root@elk build]# make && make install
-- Installing: /usr/local/share/man/man3/zip_stat_index.3
-- Installing: /usr/local/bin/zipcmp
-- Set runtime path of "/usr/local/bin/zipcmp" to ""
-- Installing: /usr/local/bin/zipmerge
-- Set runtime path of "/usr/local/bin/zipmerge" to ""
-- Installing: /usr/local/bin/ziptool
-- Set runtime path of "/usr/local/bin/ziptool" to ""

安装后需要设置环境变量

编辑文件“~/.bashrc” 添加以下环境变量

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/pkgconfig:/usr/lib64/pkgconfig:/usr/local/lib64/pkgconfig
export PKG_CONFIG_PATH

执行命令使之生效

source ~/.bashrc

检查是否安装成功,如果出现以下结果,则为成功

[root@elk build]# pkg-config --libs libzip
-L/usr/local/lib64 -lzip
[root@elk build]#

4、安装lib

  • 下载安装包:wget https://pecl.php.net/get/zip
  • 解压并进入解压目录
[root@elk wp]# tar -zxvf zip^C
[root@elk wp]#
[root@elk wp]#
[root@elk wp]# cd zip-1.21.1
[root@elk zip-1.21.1]# pwd
/u01/tool/wp/zip-1.21.1
[root@elk zip-1.21.1]# ls
config.m4  config.w32  CREDITS  examples  LICENSE  php5  php7  php73  php74  php8  php81  tests
[root@elk zip-1.21.1]#

解压目录是没有安装文件的,需要通过phpize创建安装文件

  • 查找phpize 目录
//我这里phpize 目录为  /u01/tool/wp/php8/bin/phpize
[root@elk zip-1.21.1]# find / -name phpize
/u01/tool/wp/php-8.1.18/scripts/phpize
/u01/tool/wp/php8/bin/phpize
  • 创建安装文件
[root@elk zip-1.21.1]# /u01/tool/wp/php8/bin/phpize
Configuring for:
PHP Api Version:         20210902
Zend Module Api No:      20210902
Zend Extension Api No:   420210902
[root@elk zip-1.21.1]# ls
# 可以看出 执行后 有了configure 文件
autom4te.cache  config.h.in  configure     config.w32  examples  php5  php73  php8   run-tests.php
build           config.m4    configure.ac  CREDITS     LICENSE   php7  php74  php81  tests
[root@elk zip-1.21.1]#
  • 查找php-config安装目录
[root@elk zip-1.21.1]# find / -name php-config
/u01/tool/wp/php-8.1.18/scripts/php-config
/u01/tool/wp/php8/bin/php-config
  • 配置
[root@elk zip-1.21.1]# ./configure --with-php-config=/u01/tool/wp/php8/bin/php-config
.....
.....
creating libtool
appending configuration tag "CXX" to libtool
configure: patching config.h.in
configure: creating ./config.status
config.status: creating config.h
  • 编译+安装
[root@elk zip-1.21.1]# make && make install
....
....
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:- add LIBDIR to the `LD_LIBRARY_PATH' environment variableduring execution- add LIBDIR to the `LD_RUN_PATH' environment variableduring linking- use the `-Wl,--rpath -Wl,LIBDIR' linker flag- have your system administrator add LIBDIR to `/etc/ld.so.conf'See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------Build complete.
Don't forget to run 'make test'.Installing shared extensions:     /u01/tool/wp/php8/lib/php/extensions/no-debug-non-zts-20210902/
  • 查看是否有zip.so文件

我们本地so文件地址:

[root@elk zip-1.21.1]# find / -name zip.so
/u01/tool/wp/php8/lib/php/extensions/no-debug-non-zts-20210902/zip.so
/u01/tool/wp/zip-1.21.1/modules/zip.so
/u01/tool/wp/zip-1.21.1/.libs/zip.so
[root@elk zip-1.21.1]#
  • 更改php.ini

在最后添加

extension=zip.so

修改

zlib.output_compression = Off

改为

zlib.output_compression = On

  • 建立软连接
[root@elk daemon]# ln -s /u01/tool/wp/php8/lib/php/extensions/no-debug-non-zts-20210902/zip.so /usr/lib64/zip.so  && ldconfig
[root@elk daemon]#
[root@elk daemon]#
[root@elk daemon]# ln -s /u01/tool/wp/php8/lib/php/extensions/no-debug-non-zts-20210902/zip.so /usr/lib/zip.so  && ldconfig
[root@elk daemon]#
[root@elk daemon]#
[root@elk daemon]# ldconfig /usr/local/lib64
[root@elk daemon]#
[root@elk daemon]# ldconfig /usr/local/lib
  • 重启php

启动报错,解决中.....

[root@elk daemon]# ./php-fpm start
Starting php-fpm [22-Apr-2023 21:34:57] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library 'zip.so' (tried: /u01/tool/wp/php8/lib/php/extensions/no-debug-non-zts-20210902/zip.so (libzip.so.5: cannot open shared object file: No such file or directory), /u01/tool/wp/php8/lib/php/extensions/no-debug-non-zts-20210902/zip.so.so (/u01/tool/wp/php8/lib/php/extensions/no-debug-non-zts-20210902/zip.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
 done

问题解决:

编辑/etc/ld.so.conf文件把库文件目录加上,关闭php-fpm,然后重启即可

vim /etc/ld.so.conf
include ld.so.conf.d/*.conf  # 默认只有这一行
/usr/lib64
/usr/lib
/usr/local/lib
/usr/local/lib64

5、检查扩展是否安装成功

通过“php -m” (在php安装目录的bin目录中)检查扩展是否安装成功

linux 安装php8.1 ZipArchive和libzip最新版扩展安装相关推荐

  1. Ubuntu 安装 php8.1

    虽然这段时间一直是在用 go 开发,但 PHP 对我的影响一直影响着我,语言只是一种工具,所用的场景一直都是由使用者来决定.虽然 PHP 没有前几年那么受欢迎,但它也在往前发展,变的越来越好. 在平时 ...

  2. mongodb php linux,mongodb 及PHP的MongoDB 扩展安装

    Install MongoDB https://www.mongodb.org/downloads 第一种 通用二进制包安装 curl -O https://fastdl.mongodb.org/li ...

  3. linux虚拟机镜像_无树莓派硬件体验:虚拟机安装 Raspberry Pi Desktop 操作系统

    树莓派官方的 raspbian 操作系统有 PC 版本,就是能用来安装到自己的电脑上.可能是官方的推广策略,先把树莓派系统推出来,让大家可以在 PC 上体验. 这篇文章就教大家,如何在电脑虚拟机上安装 ...

  4. linux下Redis以及phpredis扩展安装

    linux下Redis以及phpredis扩展安装 首先安装redis: 一.下载redis: wgethttp://download.redis.io/releases/redis-2.8.10.t ...

  5. [PXE] Linux(centos6)中PXE 服务器搭建,PXE安装、启动及PXE理论详解

    本篇blog主要讲述了[PXE] linux(centos)PXE无盘服务器搭建,安装,启动及pxe协议详解 , Kickstart (PXE+DHCP+TFTP+HTTP). PXE环境概述 作为中 ...

  6. Kali Linux 安全渗透教程第六更1.4.2 安装至USB驱动器Kali Linux

    1.4.2  安装至USB驱动器Kali Linux 安全渗透教程<第六更> Kali Linux USB驱动器提供了一种能力,它能永久的保存系统设置.永久更新.在USB设备上安装软件包, ...

  7. linux usb全自动安装,制作liveusb实现centos6.2全自动无人职守安装

    这几天一直在研究u盘全自动安装centos,把具体过程分享一下供参考,同时也做为我个人的一个备忘 主要准备以下4样东西 1.8G以上u盘一只 2.CentOS镜像CentOS-6.2-x86_64-b ...

  8. linux 爬虫工具,技术|如何在Ubuntu 14.04 LTS安装网络爬虫工具:Scrapy

    这是一款提取网站数据的开源工具.Scrapy框架用Python开发而成,它使抓取工作又快又简单,且可扩展.我们已经在virtual box中创建一台虚拟机(VM)并且在上面安装了Ubuntu 14.0 ...

  9. Linux学习笔记4-三种不同类型的软件的安装(绿色软件、rpm软件、源代码软件)...

    在Linux下软件分三种: 1.绿色软件:即不用安装直接就能用的软件 2.rpm安装包:以rpm结尾的可执行文件  3.源码文件:没有进行过编译和打包的文件,需要编译后再进行安装 一.绿色软件的安装 ...

最新文章

  1. Nature子刊 | 研究人员提出神经脆性可作为癫痫发作区(SOZ)的脑电图(EEG)标志物
  2. 第三次学JAVA再学不好就吃翔(part89)--HashSet
  3. 你没有权限在此位置中保持文件 java_Java路径问题解决方案收集
  4. windows系统 ping Telnet等系统自带命令无法使用原因及解决方法
  5. 关于在项目中使用开源项目的疑惑,恳请大家给点意见!
  6. 通过filebeat、logstash、rsyslog采集nginx日志的几种方式
  7. 开发项目的简单流程(需求、数据库、编码)
  8. 考场自动安排工具开发手记
  9. 分享168套HTML个人博客模板---总有一个是你想要的
  10. 串口通信(232,485,422)以及常见问题
  11. 戴尔服务器进入pxe启动
  12. 海康威视高级副总裁毕会娟:全面解读“物信融合数据平台”的功能与业务逻辑...
  13. kali安装软件源软件
  14. 【dgl学习】dgl的构图和使用
  15. 计算机专业新生创新思维研究,计算机基础与计算思维探究论文
  16. python爬取微博热搜榜
  17. ASBR上配置外部OSPF路由汇总
  18. 深度好文|面试官:进程和线程,我只问这19个问题
  19. 安装打印机显示域服务器不可用,Win7系统打印出错提示“Active Directory域服务当前不可用”怎么解决...
  20. 在Elasticsearch使用URI花式搜索

热门文章

  1. IT专业大学生毕业前必做的1010件事
  2. git reset revert rebase 区别
  3. 理解XaaS(SaaS、Baas、Paas、Iaas)
  4. 张驰咨询:六西格玛如何帮助公司减少客户投诉
  5. Facebook授权登录获取应用编号和应用密钥及配置
  6. 820机械设计考研真题(2021年)
  7. Internet History, Technology, and Security(week 1)
  8. 为什么很多人工作都不开心?
  9. 王海桑《爷爷是个老头》
  10. MathType7简体中文版数学公式编辑器下载安装教程