1.安装python-devel:这个软件包是 libxml2 的依赖包,如果不安装,libxml2 安装就会报错。这个软件包只是一个底层依赖包,所以安装 RPM 包即可。命令如下:
[root@CncLucZK src]# yum -y install python-devel #没有匹配包
Repository epel is listed more than once in the configuration
Last metadata expiration check: 0:11:56 ago on Tue 01 Nov 2022 05:17:25 PM CST.
No match for argument: python-devel
Error: Unable to find a match
[root@CncLucZK src]# yum -y install python36-devel #使用3.6版本去安装。
Installed:
python36-devel-3.6.8-38.module_el8.5.0+895+a459eca8.x86_64
platform-python-devel-3.6.8-41.el8.x86_64
python3-rpm-generators-5-7.el8.noarch
python3-pip-wheel-9.0.3-20.el8.noarch
python3-setuptools-wheel-39.2.0-6.el8.noarch
Complete!
2.进入解压缩之后的源码目录:这一步不能省略,因为 “./configure”、“make” 和 “make install” 操作的都是当前所在目录,所以一定要进入解压缩之后的源码目录。命令如下:
[root@CncLucZK src]# cd libxml2-2.9.12
3.编译前的准备和配置:这一步主要检查安装需要的系统环境、配置软件需要的功能选项,并生成配置安装文件 Makefile,以后的编译与编译安装过程需要依赖 Makefile 文件。命令如下:
Configure则是一个可执行文件,可以配置很多选项(可以理解为我们在Windows安装时的图像化界面的功能),可以通过./configure --help来查看选项具体含义。其中–prefix选项作用是配置源码安装的路径
[root@CncLucZK ~]# ./configure --prefix=/usr/local/libxml2/
-bash: ./configure: No such file or directory
[root@CncLucZK ~]# find -name configure
[root@CncLucZK ~]# cd /
[root@CncLucZK /]# find -name configure
./usr/local/src/libpng-1.6.38/configure
./usr/local/src/libmcrypt-2.5.8/configure
./usr/local/src/libmcrypt-2.5.8/libltdl/configure
./usr/local/src/zlib-1.2.13/configure
./usr/local/src/libgd-2.1.1/configure
./usr/local/src/mysql-8.0.31/extra/libedit/libedit-20210910-3.1/configure
./usr/local/src/mysql-8.0.31/extra/icu/icu-release-69-1/source/configure
./usr/local/src/mysql-8.0.31/extra/zlib/zlib-1.2.12/configure
./usr/local/src/mysql-8.0.31/extra/protobuf/protobuf-3.19.4/configure
./usr/local/src/freetype-2.10.0/configure
./usr/local/src/freetype-2.10.0/builds/unix/configure
./usr/local/src/apr-util-1.6.1/configure
./usr/local/src/mcrypt-2.6.8/configure
./usr/local/src/httpd-2.4.54/configure
./usr/local/src/ncurses-6.3-20221029/Ada95/configure
./usr/local/src/ncurses-6.3-20221029/configure
./usr/local/src/ncurses-6.3-20221029/test/configure
./usr/local/src/mhash-0.9.9.9/configure
./usr/local/src/mhash-0.9.9.9/mhash-0.9.9/configure
./usr/local/src/jpeg-6b/configure
./usr/local/src/pcre-8.45/configure
./usr/local/src/libxml2-2.9.12/configure
./usr/local/src/php-8.1.12/configure
./usr/local/src/memcached-1.6.17/configure
./usr/local/src/apr-1.7.0/configure
./usr/share/bash-completion/completions/configure
./usr/share/doc/readline-devel/rlfe/configure
./usr/lib/firmware/configure
#找到对应安装软件下的configure文件,然后cd到文件所在的目录再次执行配置命令
[root@CncLucZK libxml2-2.9.12]# ./configure --prefix=/usr/local/libxml2
...
config.status: executing depfiles commands
config.status: executing libtool commands
Done configuring
错误提示:./configure报-bash: ./configure: No such file or directory
分析原因:
1、在你配置指定路径时没有这样的文件或目录存在,先创建一个目录。
2、可能现在执行的目录下没有configure 程序,你无法执行,你到configure所在目录下重新执行语句.使用find -name configure找到文件,然后cd到文件所在的目录再次执行配置命令即可
4.编译:也就是依靠 gcc 把源码包翻译为二进制的机器语言包。命令如下:
[root@CncLucZK libxml2-2.9.12]# make
...
Making all in xstc
make[2]: Entering directory '/usr/local/src/libxml2-2.9.12/xstc'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/usr/local/src/libxml2-2.9.12/xstc'
make[1]: Leaving directory '/usr/local/src/libxml2-2.9.12'
以上的编译前配置和编译都不会在 /usr/local/ 目录中写入任何数据,只会在源码目录中生成 Makefile 等临时文件。所以,如果报错了,则只需执行“make clean”命令清除缓存和临时文件,再进行安装即可。
5.编译安装:这一步才会真正向 /usr/local/ 目录中写入数据。命令如下:
[root@CncLucZK libxml2-2.9.12]# make install
...
make[3]: Leaving directory '/usr/local/src/libxml2-2.9.12/xstc'
make[2]: Leaving directory '/usr/local/src/libxml2-2.9.12/xstc'
make[1]: Leaving directory '/usr/local/src/libxml2-2.9.12'
[root@CncLucZK libxml2-2.9.12]# ll /usr/local/libxml2
total 16
drwxr-xr-x 2 root root 4096 Nov 1 18:11 bin
drwxr-xr-x 3 root root 4096 Nov 1 18:11 include
drwxr-xr-x 4 root root 4096 Nov 1 18:11 lib
drwxr-xr-x 6 root root 4096 Nov 1 18:11 share