Linux软件包管理


一、挂载ios镜像

  • 步骤一:确定自己正在使用的镜像

06-Linux软件包管理 - 图1

  • 步骤二:开机,检查是否配置成功——右下角驱动图标为绿色则为配置成功

06-Linux软件包管理 - 图2

  • 步骤三:将光驱挂载到系统中
  1. [root@myserver ~]# mount /dev/sr0 /mnt
  2. mount: /mnt: WARNING: device write-protected, mounted read-only.
  3. [root@myserver ~]# df -h
  4. Filesystem Size Used Avail Use% Mounted on
  5. devtmpfs 1.9G 0 1.9G 0% /dev
  6. tmpfs 1.9G 0 1.9G 0% /dev/shm
  7. tmpfs 1.9G 10M 1.9G 1% /run
  8. tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
  9. /dev/mapper/cl-root 36G 4.5G 31G 13% /
  10. /dev/sda1 976M 193M 716M 22% /boot
  11. /dev/sdb1 5.0G 68M 5.0G 2% /data/sdb1
  12. tmpfs 376M 1.2M 375M 1% /run/user/42
  13. tmpfs 376M 4.6M 371M 2% /run/user/0
  14. /dev/sr0 7.7G 7.7G 0 100% /mnt
  15. -------------------------------------------------------------------------
  16. · /dev/sr0 在/dev目录下,cdromsr0均为光驱设备,我们选择sr0进行挂载

二、rpm软件包管理

  • Windows应用:exe包
  • Mac OS应用:dmg包
  • Linux应用:rpm包
  • 如果我们的应用可以直接安装时可以直接使用rpm;如果我们的应用在安装时还需要依赖其他包,使用rpm进行安装就会很麻烦(需要将所有的包一个一个rpm -ivh进行安装)
  • rpm软件包管理工具常用命令
    • rpm -qa —> 查看已安装的所有rpm包
    • rpm -qa | grep 关键字 —> 查看所有带有关键字的已安装rpm包
    • rpm -ivh xxx.rpm —> 安装xxx. rpm
    • rpm -e xxx —> 卸载已安装的xxx(不需要.rmp后缀)
    • rpm -Uvh xxx.rpm —> 更新xxx.rpm

举例

  1. [root@myserver ~]# cd /mnt
  2. [root@myserver mnt]# ls
  3. AppStream BaseOS EFI images isolinux media.repo TRANS.TBL
  4. [root@myserver mnt]# cd BaseOS/
  5. [root@myserver BaseOS]# ls
  6. Packages repodata
  7. [root@myserver BaseOS]# cd Packages/
  8. [root@myserver Packages]# ls
  9. aajohan-comfortaa-fonts-3.001-2.el8.noarch.rpm
  10. acl-2.2.53-1.el8.x86_64.rpm
  11. acpica-tools-20180629-3.el8.x86_64.rpm
  12. adcli-0.8.2-5.el8.x86_64.rpm
  13. adcli-doc-0.8.2-5.el8.noarch.rpm
  14. arpwatch-2.1a15-44.el8.x86_64.rpm
  15. .......
  16. ------------------------------------------------------------------------------------------
  17. · 在我们挂载的光驱下,有BaseOS文件夹,其下有Packages文件夹,在Packages文件夹下有光驱提供的所有可直接进行安装的rpm
  18. · 下面我们以xz-devel举例
  19. ------------------------------------------------------------------------------------------
  20. [root@myserver Packages]# ls | grep xz
  21. xz-5.2.4-3.el8.x86_64.rpm
  22. xz-devel-5.2.4-3.el8.i686.rpm
  23. xz-devel-5.2.4-3.el8.x86_64.rpm
  24. xz-libs-5.2.4-3.el8.i686.rpm
  25. xz-libs-5.2.4-3.el8.x86_64.rpm
  26. # 查看安装的xz包
  27. [root@myserver Packages]# rpm -qa | grep xz
  28. xz-5.2.4-3.el8.x86_64
  29. xz-libs-5.2.4-3.el8.x86_64
  30. # 安装xz-devel
  31. [root@myserver Packages]# rpm -ivh xz-devel-5.2.4-3.el8.x86_64.rpm
  32. warning: xz-devel-5.2.4-3.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 8483c65d: NOKEY
  33. Verifying... ################################# [100%]
  34. Preparing... ################################# [100%]
  35. Updating / installing...
  36. 1:xz-devel-5.2.4-3.el8 ################################# [100%]
  37. # 检测是否安装成功
  38. [root@myserver Packages]# rpm -qa | grep xz
  39. xz-devel-5.2.4-3.el8.x86_64
  40. xz-5.2.4-3.el8.x86_64
  41. xz-libs-5.2.4-3.el8.x86_64
  42. ------------------------------------------------------------------------------------------
  43. # 查看安装的rpm包
  44. [root@myserver Packages]# rpm -qa | grep xz
  45. xz-devel-5.2.4-3.el8.x86_64
  46. xz-5.2.4-3.el8.x86_64
  47. xz-libs-5.2.4-3.el8.x86_64
  48. # 卸载xz-devel
  49. [root@myserver Packages]# rpm -e xz-devel-5.2.4-3.el8.x86_64
  50. # 检测是否卸载成功
  51. [root@myserver Packages]# rpm -qa | grep xz
  52. xz-5.2.4-3.el8.x86_64
  53. xz-libs-5.2.4-3.el8.x86_64

三、yum软件包管理

  • yum仓库 —> yum源
  • 源的配置需要的是一个xxx.repo文件(在/etc/yum.repos.d文件夹下进行配置)
  • yum软件包管理工具常用命令
    • yum repolist —> 查看所有可用yum源
    • yum repolist all —> 查看所有yum源及其状态
    • yum -y install xxx —-> 安装xxx软件(-y参数表示安装过程中不需要用户再进行确认)‘
    • yum remove xxx —> 卸载xxx软件
    • yum update xxx —> 更新xxx软件
    • yum clean all —> 清理yum运行缓存

1. 准备工作

  • 备份初始源
  1. [root@myserver Packages]# cd /etc/yum.repos.d/
  2. [root@myserver yum.repos.d]# ls
  3. CentOS-AppStream.repo CentOS-Devel.repo CentOS-PowerTools.repo
  4. CentOS-Base.repo CentOS-Extras.repo CentOS-Sources.repo
  5. CentOS-centosplus.repo CentOS-fasttrack.repo CentOS-Vault.repo
  6. CentOS-CR.repo CentOS-HA.repo
  7. CentOS-Debuginfo.repo CentOS-Media.repo
  8. [root@myserver yum.repos.d]# mkdir bak
  9. [root@myserver yum.repos.d]# mv *.repo bak/
  10. [root@myserver yum.repos.d]# ls
  11. bak
  • yum源格式
  1. [root@myserver yum.repos.d]# cd bak/
  2. [root@myserver bak]# ls
  3. CentOS-AppStream.repo CentOS-Devel.repo CentOS-PowerTools.repo
  4. CentOS-Base.repo CentOS-Extras.repo CentOS-Sources.repo
  5. CentOS-centosplus.repo CentOS-fasttrack.repo CentOS-Vault.repo
  6. CentOS-CR.repo CentOS-HA.repo
  7. CentOS-Debuginfo.repo CentOS-Media.repo
  8. # 查看yum源格式
  9. [root@myserver bak]# cat CentOS-Base.repo
  10. [BaseOS] # 仓库id
  11. name=CentOS-$releasever - Base # 仓库名称
  12. baseurl=http://mirror.centos.org/$contentdir/$releasever/BaseOS/$basearch/os/ # 源地址,分为在线源(http://)和本地源(file://)
  13. gpgcheck=1 # 是否进行证书验证,1为验证,0为不验证
  14. enabled=1 # 是否启动,1为启动,0为不启动
  15. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial # 进行证书验证的钥匙

2. 配置本地yum源及检测

  • 配置本地yum源
  1. [root@myserver bak]# cd ..
  2. [root@myserver yum.repos.d]# ls
  3. bak
  4. # 编辑本地yum源
  5. [root@myserver yum.repos.d]# vim myRepo.repo
  6. # 本地源配置
  7. [myRepo]
  8. name=My first repo.
  9. baseurl=file:///mnt/BaseOS/
  10. gpgcheck=0
  11. enabled=1
  12. # 查看是否配置成功
  13. [root@myserver yum.repos.d]# yum repolist
  14. repo id repo name
  15. myRepo My first repo.
  • 安装软件进行检测
  1. # 查看当前已安装的xz包
  2. [root@myserver yum.repos.d]# rpm -qa | grep xz
  3. xz-5.2.4-3.el8.x86_64
  4. xz-libs-5.2.4-3.el8.x86_64
  5. # 使用yum命令安装xz-devel
  6. [root@myserver yum.repos.d]# yum -y install xz-devel
  7. Last metadata expiration check: 0:01:08 ago on Mon 27 Jul 2020 01:53:34 PM CST.
  8. Dependencies resolved.
  9. =======================================================================================
  10. Package Architecture Version Repository Size
  11. =======================================================================================
  12. Installing:
  13. xz-devel x86_64 5.2.4-3.el8 myRepo 62 k
  14. Transaction Summary
  15. =======================================================================================
  16. Install 1 Package
  17. Total size: 62 k
  18. Installed size: 202 k
  19. Downloading Packages:
  20. Running transaction check
  21. Transaction check succeeded.
  22. Running transaction test
  23. Transaction test succeeded.
  24. Running transaction
  25. Preparing : 1/1
  26. Installing : xz-devel-5.2.4-3.el8.x86_64 1/1
  27. Running scriptlet: xz-devel-5.2.4-3.el8.x86_64 1/1
  28. Verifying : xz-devel-5.2.4-3.el8.x86_64 1/1
  29. Installed products updated.
  30. Installed:
  31. xz-devel-5.2.4-3.el8.x86_64
  32. Complete!
  33. # 检测xz-devel是否安装成功
  34. [root@myserver yum.repos.d]# rpm -qa | grep xz
  35. xz-devel-5.2.4-3.el8.x86_64
  36. xz-5.2.4-3.el8.x86_64
  37. xz-libs-5.2.4-3.el8.x86_64
  38. # 使用yum命令卸载xz-devel
  39. [root@myserver yum.repos.d]# yum -y remove xz-devel
  40. Dependencies resolved.
  41. =======================================================================================
  42. Package Architecture Version Repository Size
  43. =======================================================================================
  44. Removing:
  45. xz-devel x86_64 5.2.4-3.el8 @myRepo 202 k
  46. Transaction Summary
  47. =======================================================================================
  48. Remove 1 Package
  49. Freed space: 202 k
  50. Running transaction check
  51. Transaction check succeeded.
  52. Running transaction test
  53. Transaction test succeeded.
  54. Running transaction
  55. Preparing : 1/1
  56. Erasing : xz-devel-5.2.4-3.el8.x86_64 1/1
  57. Running scriptlet: xz-devel-5.2.4-3.el8.x86_64 1/1
  58. Verifying : xz-devel-5.2.4-3.el8.x86_64 1/1
  59. Installed products updated.
  60. Removed:
  61. xz-devel-5.2.4-3.el8.x86_64
  62. Complete!
  63. # 检测xz-devel是否卸载成功
  64. [root@myserver yum.repos.d]# rpm -qa | grep xz
  65. xz-5.2.4-3.el8.x86_64
  66. xz-libs-5.2.4-3.el8.x86_64

3. 配置在线yum源及检测

  • 配置在线yum源
  1. [root@myserver yum.repos.d]# ls
  2. bak myRepo.repo
  3. # 备份本地yum
  4. [root@myserver yum.repos.d]# mv myRepo.repo myRepo.repo~
  5. [root@myserver yum.repos.d]# ls
  6. bak myRepo.repo~
  7. # 创建在线yum
  8. [root@myserver yum.repos.d]# vim myRepo.repo
  9. # 在线yum源配置
  10. [myRepo2]
  11. name=My second repo.
  12. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/8.2.2004/BaseOS/x86_64/os/
  13. gpgcheck=0
  14. enabled=1
  15. [root@myserver yum.repos.d]# ls
  16. bak myRepo.repo myRepo.repo~
  17. # 查看是否配置成功
  18. [root@myserver yum.repos.d]# yum repolist
  19. repo id repo name
  20. myRepo2 My second repo.
  • 安装软件进行检测
  1. # 清理之前的缓存
  2. [root@myserver yum.repos.d]# yum clean all
  3. 32 files removed
  4. # 查看当前xz包的安装情况
  5. [root@myserver yum.repos.d]# rpm -qa | grep xz
  6. xz-5.2.4-3.el8.x86_64
  7. xz-libs-5.2.4-3.el8.x86_64
  8. # 安装xz-devel
  9. [root@myserver yum.repos.d]# yum -y install xz-devel
  10. My second repo. 123 kB/s | 2.2 MB 00:18
  11. Dependencies resolved.
  12. =======================================================================================
  13. Package Architecture Version Repository Size
  14. =======================================================================================
  15. Installing:
  16. xz-devel x86_64 5.2.4-3.el8 myRepo2 62 k
  17. Transaction Summary
  18. =======================================================================================
  19. Install 1 Package
  20. Total download size: 62 k
  21. Installed size: 202 k
  22. Downloading Packages:
  23. xz-devel-5.2.4-3.el8.x86_64.rpm 39 kB/s | 62 kB 00:01
  24. ---------------------------------------------------------------------------------------
  25. Total 39 kB/s | 62 kB 00:01
  26. Running transaction check
  27. Transaction check succeeded.
  28. Running transaction test
  29. Transaction test succeeded.
  30. Running transaction
  31. Preparing : 1/1
  32. Installing : xz-devel-5.2.4-3.el8.x86_64 1/1
  33. Running scriptlet: xz-devel-5.2.4-3.el8.x86_64 1/1
  34. Verifying : xz-devel-5.2.4-3.el8.x86_64 1/1
  35. Installed products updated.
  36. Installed:
  37. xz-devel-5.2.4-3.el8.x86_64
  38. Complete!
  39. # 检测xz-devel是否安装成功
  40. [root@myserver yum.repos.d]# rpm -qa | grep xz
  41. xz-devel-5.2.4-3.el8.x86_64
  42. xz-5.2.4-3.el8.x86_64
  43. xz-libs-5.2.4-3.el8.x86_64
  44. # 尝试更新xz-devel,不过没有可以更新的地方
  45. [root@myserver yum.repos.d]# yum update xz-devel
  46. Last metadata expiration check: 0:00:18 ago on Mon 27 Jul 2020 02:16:44 PM CST.
  47. Dependencies resolved.
  48. Nothing to do.
  49. Complete!
  50. # 卸载xz-devel
  51. [root@myserver yum.repos.d]# yum -y remove xz-devel
  52. Dependencies resolved.
  53. =======================================================================================
  54. Package Architecture Version Repository Size
  55. =======================================================================================
  56. Removing:
  57. xz-devel x86_64 5.2.4-3.el8 @myRepo2 202 k
  58. Transaction Summary
  59. =======================================================================================
  60. Remove 1 Package
  61. Freed space: 202 k
  62. Running transaction check
  63. Transaction check succeeded.
  64. Running transaction test
  65. Transaction test succeeded.
  66. Running transaction
  67. Preparing : 1/1
  68. Erasing : xz-devel-5.2.4-3.el8.x86_64 1/1
  69. Running scriptlet: xz-devel-5.2.4-3.el8.x86_64 1/1
  70. Verifying : xz-devel-5.2.4-3.el8.x86_64 1/1
  71. Installed products updated.
  72. Removed:
  73. xz-devel-5.2.4-3.el8.x86_64
  74. Complete!
  75. # 检测是否卸载成功
  76. [root@myserver yum.repos.d]# rpm -qa | grep xz
  77. xz-5.2.4-3.el8.x86_64
  78. xz-libs-5.2.4-3.el8.x86_64

四、dnf软件包管理

  • dnf是Dandified yum的缩写,即修订版的yum;首先出现在Fedora系统中,现已成为Fedora系统默认的包管理工具
  • 与yum相比,dnf更简单、消耗内容更少、依赖包解析速度更快
  • dnf软件包管理工具常用命令
    • dnf —version —> 查看当前dnf版本信息
    • dnf check —> 检查yum源配置是否正确
    • dnf check-update —> 检查是否有软件包需要升级
    • dnf clean all —> 清理dnf运行缓存
    • dnf repolist —> 查看所有可用yum源
    • dnf repolist all —> 查看所有yum源及其状态
    • dnf list installed —> 列出系统所有已安装的包
    • dnf search xxx —> 在yum源中查找xxx包
    • dnf -y install xxx —> 安装xxx软件
    • dnf -y reinstall xxx —> 重新安装xxx软件
    • dnf -y remove xxx —> 卸载xxx软件
    • dnf download xxx —> 下载xxx软件(.rpm格式)到当前文件夹
    • dnf update xxx —> 更新xxx软件

五、源码编译安装软件

1. 归档文件

  • tar cfv 归档文件名.tar 文件1 文件2 —> 将文件1和文件2归档
  • tar xfv 归档文件名.tar -C 解压路径 —> 将归档中的文件解压到-C指定的路径下
  • tar tfv 归档文件名.tar —> 列出当前归档文件中所有文件的详细信息
  1. [root@myserver ~]# ls
  2. anaconda-ks.cfg Documents initial-setup-ks.cfg Pictures Templates
  3. Desktop Downloads Music Public Videos
  4. # 创建a.txt、b.txt、c.txt三个文件
  5. [root@myserver ~]# touch a.txt b.txt c.txt
  6. [root@myserver ~]# ls
  7. anaconda-ks.cfg b.txt Desktop Downloads Music Public Videos
  8. a.txt c.txt Documents initial-setup-ks.cfg Pictures Templates
  9. # 将三个文件归档到myTestFile.tar中
  10. [root@myserver ~]# tar cfv myTestFile.tar a.txt b.txt c.txt
  11. a.txt
  12. b.txt
  13. c.txt
  14. # 检测是否归档成功
  15. [root@myserver ~]# ls
  16. anaconda-ks.cfg c.txt Downloads myTestFile.tar Templates
  17. a.txt Desktop initial-setup-ks.cfg Pictures Videos
  18. b.txt Documents Music Public
  19. # 查看myTestFile.tar类型--->一个tar存档
  20. [root@myserver ~]# file myTestFile.tar
  21. myTestFile.tar: POSIX tar archive (GNU)
  22. # 将myTestFile.tar归档的内容解压到/usr/local/src目录下
  23. [root@myserver ~]# tar xfv myTestFile.tar -C /usr/local/src/
  24. a.txt
  25. b.txt
  26. c.txt
  27. # 查看是否解压成功
  28. [root@myserver ~]# cd /usr/local/src/
  29. [root@myserver src]# ls
  30. a.txt b.txt c.txt
  31. [root@myserver home]# cd -
  32. /root
  33. # 列出myTestFile.tar中所有文件的详细信息
  34. [root@myserver ~]# tar tfv myTestFile.tar
  35. -rw-r--r-- root/root 0 2020-07-27 16:22 a.txt
  36. -rw-r--r-- root/root 0 2020-07-27 16:22 b.txt
  37. -rw-r--r-- root/root 0 2020-07-27 16:22 c.txt
  38. # 清除测试用的归档文件
  39. [root@myserver ~]# cd /usr/local/src/
  40. [root@myserver src]# ls
  41. a.txt b.txt c.txt
  42. [root@myserver src]# rm -f a.txt b.txt c.txt
  43. [root@myserver src]# ls
  44. [root@myserver src]# cd -
  45. /root
  46. [root@myserver ~]# ls
  47. anaconda-ks.cfg c.txt Downloads myTest.tar Templates
  48. a.txt Desktop initial-setup-ks.cfg Pictures v
  49. b.txt Documents Music Public Videos
  50. [root@myserver ~]# rm -f myTest.tar
  51. [root@myserver ~]# ls
  52. anaconda-ks.cfg b.txt Desktop Downloads Music Public v
  53. a.txt c.txt Documents initial-setup-ks.cfg Pictures Templates Videos

2. tar.gz格式压缩包

  • tar zcfv 压缩包名.tar.gz 文件1 文件2 —> 创建一个tar.gz格式的压缩包
  • tar zxfv 压缩包名.tar.gz -C 解压目录 —> 将tar.gz压缩包解压到-C所指定目录下
  • tar ztfv 压缩包名.tar.gz —> 列出当前tar.gz压缩包中所有文件的详细信息(参数中没有z也可以)
  1. [root@myserver ~]# ls
  2. anaconda-ks.cfg b.txt Desktop Downloads Music Public v
  3. a.txt c.txt Documents initial-setup-ks.cfg Pictures Templates Videos
  4. # 将a.txt、b.txt、c.txt三个文件压缩到myTest.tar.gz中
  5. [root@myserver ~]# tar zcfv myTest.tar.gz a.txt b.txt c.txt
  6. a.txt
  7. b.txt
  8. c.txt
  9. # 检查是否压缩成功
  10. [root@myserver ~]# ls
  11. anaconda-ks.cfg c.txt Downloads myTest.tar.gz Templates
  12. a.txt Desktop initial-setup-ks.cfg Pictures v
  13. b.txt Documents Music Public Videos
  14. # 查看myTest.tar.gz的类型--->gzip压缩数据
  15. [root@myserver ~]# file myTest.tar.gz
  16. myTest.tar.gz: gzip compressed data, last modified: Mon Jul 27 08:39:38 2020, from Unix, original size 10240
  17. # 将myTest.tar.gz解压到/usr/local/src文件夹下
  18. [root@myserver ~]# tar zxfv myTest.tar.gz -C /usr/local/src/
  19. a.txt
  20. b.txt
  21. c.txt
  22. # 查看是否解压成功
  23. [root@myserver ~]# ls /usr/local/src/
  24. a.txt b.txt c.txt
  25. [root@myserver ~]# tar ztfv myTest.tar.gz
  26. -rw-r--r-- root/root 0 2020-07-27 16:33 a.txt
  27. -rw-r--r-- root/root 0 2020-07-27 16:34 b.txt
  28. -rw-r--r-- root/root 0 2020-07-27 16:34 c.txt
  29. # 清除测试用的压缩文件
  30. [root@myserver ~]# cd /usr/local/src/
  31. [root@myserver src]# ls
  32. a.txt b.txt c.txt
  33. [root@myserver src]# rm -f a.txt b.txt c.txt
  34. [root@myserver src]# ls
  35. [root@myserver src]# cd -
  36. /root
  37. [root@myserver ~]# ls
  38. anaconda-ks.cfg c.txt Downloads myTest.tar.gz Templates
  39. a.txt Desktop initial-setup-ks.cfg Pictures v
  40. b.txt Documents Music Public Videos
  41. [root@myserver ~]# rm -f a.txt b.txt c.txt myTest.tar.gz
  42. [root@myserver ~]# ls
  43. anaconda-ks.cfg Documents initial-setup-ks.cfg Pictures Templates Videos
  44. Desktop Downloads Music Public v

3. 源码编译安装软件过程

  • wget下载软件源码包(要联网)
  • tar zxfv命令解压源码包(默认会解压到当前文件夹下,建议用-C参数指定解压路径为/usr/local/src,或者直接在/usr/local/src目录下进行操作)
  • ./configure —> 执行配置文件
  • make —> 执行编译
  • make install -> 执行编译安装
  1. [root@myserver ~]# cd /usr/local/src/
  2. # 下载PCRE源码的压缩包
  3. [root@myserver src]# wget https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz
  4. --2020-07-27 17:07:03-- https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz
  5. Resolving ftp.pcre.org (ftp.pcre.org)... 131.111.8.88
  6. Connecting to ftp.pcre.org (ftp.pcre.org)|131.111.8.88|:443... connected.
  7. HTTP request sent, awaiting response... 200 OK
  8. Length: 2090750 (2.0M) [application/x-gunzip]
  9. Saving to: pcre-8.44.tar.gz
  10. pcre-8.44.tar.gz 100%[========================>] 1.99M 16.7KB/s in 2m 4s
  11. 2020-07-27 17:09:09 (16.4 KB/s) - pcre-8.44.tar.gz saved [2090750/2090750]
  12. [root@myserver src]# ls
  13. pcre-8.44.tar.gz
  14. # 解压获得PCRE的源码包
  15. [root@myserver src]# tar zxfv pcre-8.44.tar.gz
  16. pcre-8.44/
  17. pcre-8.44/pcre_scanner.h
  18. ......
  19. pcre-8.44/pcre32_ucd.c
  20. pcre-8.44/makevp_l.txt
  21. [root@myserver src]# ls
  22. pcre-8.44 pcre-8.44.tar.gz
  23. [root@myserver src]# cd pcre-8.44/
  24. [root@myserver pcre-8.44]# ls
  25. 132html pcre16_fullinfo.c pcrecpp_internal.h
  26. aclocal.m4 pcre16_get.c pcrecpp_unittest.cc
  27. ......
  28. configure pcre16_version.c pcre_maketables.c
  29. ......
  30. pcre16_exec.c pcrecpp.h
  31. # 执行配置文件,由于系统没有装c和c++编译器,所以没有办法解析执行
  32. [root@myserver pcre-8.44]# ./configure
  33. checking for a BSD-compatible install... /usr/bin/install -c
  34. checking whether build environment is sane... yes
  35. checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
  36. checking for gawk... gawk
  37. checking whether make sets $(MAKE)... no
  38. checking whether make supports nested variables... no
  39. checking whether make supports nested variables... (cached) no
  40. checking whether make supports the include directive... no
  41. checking for gcc... no
  42. checking for cc... no
  43. checking for cl.exe... no
  44. configure: error: in `/usr/local/src/pcre-8.44':
  45. configure: error: no acceptable C compiler found in $PATH
  46. See `config.log' for more details
  47. # 安装c和c++编译器
  48. [root@myserver pcre-8.44]# yum install gcc gcc-c++
  49. ......
  50. # 重新执行配置文件
  51. [root@myserver pcre-8.44]# ./configure
  52. checking for a BSD-compatible install... /usr/bin/install -c
  53. checking whether build environment is sane... yes
  54. ......
  55. Code coverage ................... : no
  56. # 安装make工具
  57. [root@myserver pcre-8.44]# yum -y install gcc automake autoconf libtool make
  58. ......
  59. # 执行编译
  60. [root@myserver pcre-8.44]# make
  61. rm -f pcre_chartables.c
  62. ln -s ./pcre_chartables.c.dist pcre_chartables.c
  63. make all-am
  64. make[1]: Entering directory '/usr/local/src/pcre-8.44'
  65. CC pcretest-pcretest.o
  66. CC pcretest-pcre_printint.o
  67. CC libpcre_la-pcre_byte_order.lo
  68. ......
  69. CXX pcre_stringpiece_unittest-pcre_stringpiece_unittest.o
  70. CXXLD pcre_stringpiece_unittest
  71. make[1]: Leaving directory '/usr/local/src/pcre-8.44'
  72. # 执行编译安装
  73. [root@myserver pcre-8.44]# make install
  74. make install-am
  75. make[1]: Entering directory '/usr/local/src/pcre-8.44'
  76. make[2]: Entering directory '/usr/local/src/pcre-8.44'
  77. /usr/bin/mkdir -p '/usr/local/lib'
  78. ......
  79. ln -sf pcre_version.3 /usr/local/share/man/man3/pcre32_version.3
  80. make[3]: Leaving directory '/usr/local/src/pcre-8.44'
  81. make[2]: Leaving directory '/usr/local/src/pcre-8.44'
  82. make[1]: Leaving directory '/usr/local/src/pcre-8.44'
  83. # 完成源码编译安装PCRE
  84. [root@myserver pcre-8.44]#