当前位置:   article > 正文

Linux —— 软件安装

Linux —— 软件安装

目录

一,源码包安装

二,RPM工具

RPM包的安装

RPM包升级

RPM包卸载

RPM包查询

RPM包验证和数字证书(数字签名)

三,YUM工具

YUM源

YUM查询

YUM安装

YUM升级

YUM卸载


源码包,含全部源代码,未经编译,安装时需编译;

rpm包(二进制包),事先已经过编译,安装时速度较快;

一,源码包安装

  • 相对于二进制软件包,配置和编译会相对繁琐,但可移植性好,可定制;
  • 常见源码包有两种,.tar.gz、.tar.bz2,是压缩文件需解压;
  • 配置:./configure(仅做编译相关准备工作) -> makefile(包括一组文件依赖关系及编译链接相关步骤);
  • 编译:make,将源码编译为二进制可执行程序;
  • make install,执行安装,即将可执行程序、第三方依赖包、文档复制到正确的路径下;
  • make clean(清理编译链接过程中的临时文件),make unstall(卸载);

例:安装aparch源码包,源码下载 https://httpd.apache.org/download.cgi#apache24

  1. [root@192 Desktop]# tar -zxvf http.4.52.tar.gz
  2. //缺失依赖包
  3. [root@192 httpd-2.4.52]# ./configure --prefix=/usr/local/apr
  4. checking for chosen layout... Apache
  5. checking for working mkdir -p... yes
  6. checking for grep that handles long lines and -e... /bin/grep
  7. checking for egrep... /bin/grep -E
  8. checking build system type... x86_64-pc-linux-gnu
  9. checking host system type... x86_64-pc-linux-gnu
  10. checking target system type... x86_64-pc-linux-gnu
  11. configure:
  12. configure: Configuring Apache Portable Runtime library...
  13. configure:
  14. checking for APR... no
  15. configure: error: APR not found. Please read the documentation.
  16. //可百度解决
  17. [root@192 httpd-2.4.52]# make
  18. [root@192 httpd-2.4.52]# make install
  19. [root@192 httpd-2.4.52]# usr/local/apr/bin/apachectl start
  20. [root@192 bin]# ps aux | grep 55017
  21. root 55017 0.0 0.1 76148 2952 ? Ss 22:51 0:00 /usr/local/apr/bin/httpd -k start
  22. [root@192 httpd-2.4.52]# netstat -tlun | grep 80
  23. tcp6 0 0 :::80 :::* LISTEN
  24. [root@192 httpd-2.4.52]# usr/local/apr/bin/apachectl stop

二,RPM工具

  • Red-Hat Package Manager,又称RPM is Package Manager;
  • 可打包、安装、查询、升级、卸载、校验、数据库管理,无法解决依赖关系;
  • 可执行二进制包(.rpm)和源代码包(.src.rpm);

RPM包默认安装路径

  • /etc,配置文件安装目录;
  • /usr/bin,可执行命令安装目录;
  • /usr/lib,程序所使用函数库存放位置;
  • /usr/share/doc,基本的软件使用手册存放位置;
  • /usr/share/man,帮助文件存放位置;

RPM包的安装

  • rpm -ivh 包全名
    • i,install安装;
    • -v,verbose显示更详细的信息;
    • -h,hash显示安装进度;

RPM包升级

  • rpm -Uvh 包全名
    • U,表示该软件若没有安装过会直接安装,安装过则升级至最新版本;
  • rpm -Fvh 包全名
    • F,表示该软件若没有安装过则不安装,需安装有低版本才能升级;

RPM包卸载

  • rpm -e 包名
    • e,erase表示卸载;
  • 卸载时需考虑包之间的依赖性,否则会依赖性报错;

RPM包查询

  • rpm -q 包名,query查询指定软件包;
  • rpm ​​​​​​-qa,查询所有安装的软件包;
  • rpm -qi 包名,查询软件包详细信息;
  • rpm -ql 包名,查询包的文件列表;
  • rpm -qf 系统文件名,查询系统文件属于哪个包;
  • rpm -qR 包名,requires查询包的依赖关系;

RPM包验证和数字证书(数字签名)

  • RPM包校验,即将已安装文件和/var/lib/rpm目录下的数据库内容进行比较,已确定内容是否被修改;
  • RPM包数字证书校验,用来校验RPM包本身是否被修改;

RPM包校验

  • rpm -Va,校验系统中已安装的所有软件包;
  • rpm -V 包名,校验指定软件包中的文件;
  • rpm -Vf 系统文件,校验某个文件系统是否被修改;

RPM数字证书验证

  • 数字证书,又称数字签名;如RPM包修改了,则数字证书也会改变,将无法与系统匹配,软件会无法安装;
  • 使用数字证书的方法,必须原厂公钥文件,与RPM包证书信息验证,方可安装;
  • 数字证书默认会放到系统中/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7位置处;

三,YUM工具

  • Yellow dog Updater,Modified,是一个在Fedora、Redhat,及CentOS中的shell前端软件包管理器,由python编写;
  • 基于RPM包管理,能够从指定的服务器查找且自动下载RPM包并安装,可自动处理依赖关系;

YUM源

  • 网络YUM源,如配置文件/etc/yum.repos.d/CentOS-Base.repo;
  • 本地YUM源,如配置文件/etc/yum.repos.d/CentOS-Media.repo;
  1. [wz@192 Desktop]$ ll /etc/yum.repos.d/
  2. 总用量 40
  3. -rw-r--r--. 1 root root 1664 1023 2020 CentOS-Base.repo
  4. -rw-r--r--. 1 root root 1309 1023 2020 CentOS-CR.repo
  5. -rw-r--r--. 1 root root 649 1023 2020 CentOS-Debuginfo.repo
  6. -rw-r--r--. 1 root root 314 1023 2020 CentOS-fasttrack.repo
  7. -rw-r--r--. 1 root root 630 1023 2020 CentOS-Media.repo
  8. -rw-r--r--. 1 root root 1331 1023 2020 CentOS-Sources.repo
  9. -rw-r--r--. 1 root root 8515 1023 2020 CentOS-Vault.repo
  10. -rw-r--r--. 1 root root 616 1023 2020 CentOS-x86_64-kernel.repo

YUM查询

  • yum list,查询所有安装和可安装的软件包;
  • yum list 包名,查询指定软件包的安装情况;
  • yum search 关键字,从yum源服务器上查找与关键字相关的所有软件包;
  • yum info 包名,查询指定软件包的详细详细;
  1. [wz@VM-4-4-centos ~]$ yum list sl.x86_64
  2. Loaded plugins: fastestmirror, langpacks
  3. Repository epel is listed more than once in the configuration
  4. Loading mirror speeds from cached hostfile
  5. Installed Packages
  6. sl.x86_64 5.02-1.el7 @epe
  1. [wz@VM-4-4-centos ~]$ yum info sl.x86_64
  2. Loaded plugins: fastestmirror, langpacks
  3. Repository epel is listed more than once in the configuration
  4. Loading mirror speeds from cached hostfile
  5. Installed Packages
  6. Name : sl
  7. Arch : x86_64
  8. Version : 5.02
  9. Release : 1.el7
  10. Size : 17 k
  11. Repo : installed
  12. From repo : epel
  13. Summary : Joke command for when you type 'sl' instead of 'ls'
  14. URL : https://github.com/mtoyoda/sl
  15. License : Copyright only
  16. Description : The sl (Steam Locomotive) command is a joke which displays a train on your
  17. : terminal when you accidentally type 'sl' instead of 'ls'.

YUM安装

  • yum -y install 包名
    • -y,表示自动回复yes,不加需手动回复;
    • install,表示安装;
  1. //库中无epel源,使用以下命令安装
  2. [wz@192 Desktop]$ yum install -y epel-release
  3. //安装后,库中就存在对应的源了
  4. [wz@192 Desktop]$ ll /etc/yum.repos.d/
  5. 总用量 48
  6. -rw-r--r--. 1 root root 1664 1023 2020 CentOS-Base.repo
  7. -rw-r--r--. 1 root root 1309 1023 2020 CentOS-CR.repo
  8. -rw-r--r--. 1 root root 649 1023 2020 CentOS-Debuginfo.repo
  9. -rw-r--r--. 1 root root 314 1023 2020 CentOS-fasttrack.repo
  10. -rw-r--r--. 1 root root 630 1023 2020 CentOS-Media.repo
  11. -rw-r--r--. 1 root root 1331 1023 2020 CentOS-Sources.repo
  12. -rw-r--r--. 1 root root 8515 1023 2020 CentOS-Vault.repo
  13. -rw-r--r--. 1 root root 616 1023 2020 CentOS-x86_64-kernel.repo
  14. -rw-r--r--. 1 root root 951 102 2017 epel.repo
  15. -rw-r--r--. 1 root root 1050 102 2017 epel-testing.repo
  1. [root@VM-4-4-centos ~]# yum -y install sl
  2. Loaded plugins: fastestmirror, langpacks
  3. Repository epel is listed more than once in the configuration
  4. Loading mirror speeds from cached hostfile
  5. Resolving Dependencies
  6. --> Running transaction check
  7. ---> Package sl.x86_64 0:5.02-1.el7 will be installed
  8. --> Finished Dependency Resolution
  9. Dependencies Resolved
  10. ==========================================================================================================
  11. Package Arch Version Repository Size
  12. ==========================================================================================================
  13. Installing:
  14. sl x86_64 5.02-1.el7 epel 14 k
  15. Transaction Summary
  16. ==========================================================================================================
  17. Install 1 Package
  18. Total download size: 14 k
  19. Installed size: 17 k
  20. Downloading packages:
  21. sl-5.02-1.el7.x86_64.rpm | 14 kB 00:00:00
  22. Running transaction check
  23. Running transaction test
  24. Transaction test succeeded
  25. Running transaction
  26. Installing : sl-5.02-1.el7.x86_64 1/1
  27. Verifying : sl-5.02-1.el7.x86_64 1/1
  28. Installed:
  29. sl.x86_64 0:5.02-1.el7
  30. Complete!

YUM升级

  • yum -y update,升级所有软件包;
  • yum -y update 包名,升级指定软件包;
  1. [root@VM-4-4-centos ~]# yum -y update sl
  2. Loaded plugins: fastestmirror, langpacks
  3. Repository epel is listed more than once in the configuration
  4. Loading mirror speeds from cached hostfile
  5. No packages marked for update

YUM卸载

  • yum -y remove 包名,卸载指定软件包;
    • 卸载软件包会同时卸载所有与该包有依赖关系的其他软件包,即便依赖包属于系统运行必备的文件,也会无情卸载; 
  1. [root@VM-4-4-centos ~]# yum -y remove sl
  2. Loaded plugins: fastestmirror, langpacks
  3. Repository epel is listed more than once in the configuration
  4. Resolving Dependencies
  5. --> Running transaction check
  6. ---> Package sl.x86_64 0:5.02-1.el7 will be erased
  7. --> Finished Dependency Resolution
  8. Dependencies Resolved
  9. ==========================================================================================================
  10. Package Arch Version Repository Size
  11. ==========================================================================================================
  12. Removing:
  13. sl x86_64 5.02-1.el7 @epel 17 k
  14. Transaction Summary
  15. ==========================================================================================================
  16. Remove 1 Package
  17. Installed size: 17 k
  18. Downloading packages:
  19. Running transaction check
  20. Running transaction test
  21. Transaction test succeeded
  22. Running transaction
  23. Erasing : sl-5.02-1.el7.x86_64 1/1
  24. Verifying : sl-5.02-1.el7.x86_64 1/1
  25. Removed:
  26. sl.x86_64 0:5.02-1.el7
  27. Complete!

yum 趣味小游戏

  • 牛说,yum -y install cowsay;
  • 变字符,yum -y install figlet;

注:验证网络通畅 —— ping www.baidu.com

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/176818
推荐阅读
相关标签
  

闽ICP备14008679号