Linux之Redhat PHP7.4.6自行编译安装

背景

安装的 Redhat 下默认php版本是5.3,想要更新到7.4.6版本实现多版本开发使用,但是服务器是处于断网状态。

步骤

  1. 从官网下载对应版本的安装包 php-7.4.6.tar.gz (sig),然后通过 Xftp6 上传到服务器

  2. 解压,进入到解压目录,执行一下配置命令 ./configure 配置一下php,此处我用 --prefix 指定了一个安装目录

    [root@lbsdb php-7.4.6]# ./configure --prefix=/usr/local/php7.4.6
    
  3. 接下来继续安装php

    	[root@lbsdb php-7.4.6]# ./configure --prefix=/usr/local/php7.4.6
    	+--------------------------------------------------------------------+
    	| License:                                                           |
    	| This software is subject to the PHP License, available in this     |
    	| distribution in the file LICENSE. By continuing this installation  |
    	| process, you are bound by the terms of this license agreement.     |
    	| If you do not agree with the terms of this license, you must abort |
    	| the installation process at this point.                            |
    	+--------------------------------------------------------------------+
    	
    	Thank you for using PHP.
    
    	```
    
    

FQA.

  • 安装过程中出现错误信息,提示你缺少 libxml-2.0 ,而且得是版本不低于 2.7.6

    Configuring extensions
    checking io.h usability... no
    checking io.h presence... no
    checking for io.h... no
    checking for strtoll... yes
    checking for atoll... yes
    checking whether to build with LIBXML support... yes
    checking for libxml-2.0 >= 2.7.6... no
    configure: error: Package requirements (libxml-2.0 >= 2.7.6) were not met:
    
    No package 'libxml-2.0' found
    
    Consider adjusting the PKG_CONFIG_PATH environment variable if you
    installed software in a non-standard prefix.
    
  • 解决办法:安装 包libxml-2.0,去访问 Linux/Unix软件包网站,
    此处注意你的 libxml2-devel的版本 ,我的环境版本是2.7.6

    [root@lbsdb download]# yum list|grep libxml2-devel
    libxml2-devel.i686                        2.7.6-21.el6_8.1               base   
    libxml2-devel.x86_64                      2.7.6-21.el6_8.1               base 
    

    所以找了对应的2.7.6版本的进行下载,进入到下载页面,找到下方Download栏目,复制链接进行下载。Linux之Redhat PHP7.4.6自行编译安装_第1张图片

    下载完成后,上传到服务器,用 rpm 命令安装

    [root@lbsdb download]# rpm -ivh libxml2-devel-2.7.6-21.el6_8.1.x86_64.rpm 
    Preparing...                ########################################### [100%]
       1:libxml2-devel          ########################################### [100%]
    
  • 其他依赖版本或缺失的情况,还是按照上方方法进行解决

    ### configure php , 缺失sqlite3
    checking for sqlite3 > 3.7.4... no
    configure: error: Package requirements (sqlite3 > 3.7.4) were not met:
    
    No package 'sqlite3' found
    
    ### 安装 sqlite,sqlite-devel 3.7版本的
    ### http://mirror.centos.org/centos/7/os/x86_64/Packages/sqlite-devel-3.7.17-8.el7_7.1.x86_64.rpm
    ### http://mirror.centos.org/centos/7/os/x86_64/Packages/sqlite-3.7.17-8.el7_7.1.x86_64.rpm
    
    ### 安装sqlite缺失 libc
    [root@lbsdb download]# rpm -ivh sqlite-3.7.17-8.el7_7.1.x86_64.rpm 
    warning: sqlite-3.7.17-8.el7_7.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    error: Failed dependencies:
    	libc.so.6(GLIBC_2.14)(64bit) is needed by sqlite-3.7.17-8.el7_7.1.x86_64
    
    ### 安装 glibc 和 glibc-devel 和 glibc-common 和 glibc-headers 3.17版本的
    ### http://mirror.centos.org/centos/7/os/x86_64/Packages/glibc-devel-2.17-307.el7.1.x86_64.rpm
    ### http://mirror.centos.org/centos/7/os/x86_64/Packages/glibc-2.17-307.el7.1.x86_64.rpm
    ### http://mirror.centos.org/centos/7/os/x86_64/Packages/glibc-common-2.17-307.el7.1.x86_64.rpm
    ### 	http://mirror.centos.org/centos/7/os/x86_64/Packages/glibc-headers-2.17-307.el7.1.x86_64.rpm
    ### 如果遇到 缺失 /usr/bin/bash, rpm --force --nodeps 包名
    

# 博客小菜鸟,记录日常,不喜尽情喷。

你可能感兴趣的:(Linux,PHP)