目录
源码包,含全部源代码,未经编译,安装时需编译;
rpm包(二进制包),事先已经过编译,安装时速度较快;
一,源码包安装
- 相对于二进制软件包,配置和编译会相对繁琐,但可移植性好,可定制;
- 常见源码包有两种,.tar.gz、.tar.bz2,是压缩文件需解压;
- 配置:./configure(仅做编译相关准备工作) -> makefile(包括一组文件依赖关系及编译链接相关步骤);
- 编译:make,将源码编译为二进制可执行程序;
- make install,执行安装,即将可执行程序、第三方依赖包、文档复制到正确的路径下;
- make clean(清理编译链接过程中的临时文件),make unstall(卸载);
例:安装aparch源码包,源码下载 https://httpd.apache.org/download.cgi#apache24;
[root@192 Desktop]# tar -zxvf http.4.52.tar.gz
//缺失依赖包
[root@192 httpd-2.4.52]# ./configure --prefix=/usr/local/apr
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no
configure: error: APR not found. Please read the documentation.
//可百度解决
[root@192 httpd-2.4.52]# make
[root@192 httpd-2.4.52]# make install
[root@192 httpd-2.4.52]# usr/local/apr/bin/apachectl start
[root@192 bin]# ps aux | grep 55017
root 55017 0.0 0.1 76148 2952 ? Ss 22:51 0:00 /usr/local/apr/bin/httpd -k start
[root@192 httpd-2.4.52]# netstat -tlun | grep 80
tcp6 0 0 :::80 :::* LISTEN
[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;
[wz@192 Desktop]$ ll /etc/yum.repos.d/
总用量 40
-rw-r--r--. 1 root root 1664 10月 23 2020 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 10月 23 2020 CentOS-CR.repo
-rw-r--r--. 1 root root 649 10月 23 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 10月 23 2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 10月 23 2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 10月 23 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 10月 23 2020 CentOS-Vault.repo
-rw-r--r--. 1 root root 616 10月 23 2020 CentOS-x86_64-kernel.repo
YUM查询
- yum list,查询所有安装和可安装的软件包;
- yum list 包名,查询指定软件包的安装情况;
- yum search 关键字,从yum源服务器上查找与关键字相关的所有软件包;
- yum info 包名,查询指定软件包的详细详细;
[wz@VM-4-4-centos ~]$ yum list sl.x86_64
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
Installed Packages
sl.x86_64 5.02-1.el7 @epe
[wz@VM-4-4-centos ~]$ yum info sl.x86_64
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
Installed Packages
Name : sl
Arch : x86_64
Version : 5.02
Release : 1.el7
Size : 17 k
Repo : installed
From repo : epel
Summary : Joke command for when you type 'sl' instead of 'ls'
URL : https://github.com/mtoyoda/sl
License : Copyright only
Description : The sl (Steam Locomotive) command is a joke which displays a train on your
: terminal when you accidentally type 'sl' instead of 'ls'.
YUM安装
- yum -y install 包名
- -y,表示自动回复yes,不加需手动回复;
- install,表示安装;
//库中无epel源,使用以下命令安装
[wz@192 Desktop]$ yum install -y epel-release
//安装后,库中就存在对应的源了
[wz@192 Desktop]$ ll /etc/yum.repos.d/
总用量 48
-rw-r--r--. 1 root root 1664 10月 23 2020 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 10月 23 2020 CentOS-CR.repo
-rw-r--r--. 1 root root 649 10月 23 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 10月 23 2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 10月 23 2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 10月 23 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 10月 23 2020 CentOS-Vault.repo
-rw-r--r--. 1 root root 616 10月 23 2020 CentOS-x86_64-kernel.repo
-rw-r--r--. 1 root root 951 10月 2 2017 epel.repo
-rw-r--r--. 1 root root 1050 10月 2 2017 epel-testing.repo
[root@VM-4-4-centos ~]# yum -y install sl
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package sl.x86_64 0:5.02-1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================================================================
Package Arch Version Repository Size
==========================================================================================================
Installing:
sl x86_64 5.02-1.el7 epel 14 k
Transaction Summary
==========================================================================================================
Install 1 Package
Total download size: 14 k
Installed size: 17 k
Downloading packages:
sl-5.02-1.el7.x86_64.rpm | 14 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : sl-5.02-1.el7.x86_64 1/1
Verifying : sl-5.02-1.el7.x86_64 1/1
Installed:
sl.x86_64 0:5.02-1.el7
Complete!
YUM升级
- yum -y update,升级所有软件包;
- yum -y update 包名,升级指定软件包;
[root@VM-4-4-centos ~]# yum -y update sl
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
No packages marked for update
YUM卸载
- yum -y remove 包名,卸载指定软件包;
- 卸载软件包会同时卸载所有与该包有依赖关系的其他软件包,即便依赖包属于系统运行必备的文件,也会无情卸载;
[root@VM-4-4-centos ~]# yum -y remove sl
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Resolving Dependencies
--> Running transaction check
---> Package sl.x86_64 0:5.02-1.el7 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================================================================
Package Arch Version Repository Size
==========================================================================================================
Removing:
sl x86_64 5.02-1.el7 @epel 17 k
Transaction Summary
==========================================================================================================
Remove 1 Package
Installed size: 17 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : sl-5.02-1.el7.x86_64 1/1
Verifying : sl-5.02-1.el7.x86_64 1/1
Removed:
sl.x86_64 0:5.02-1.el7
Complete!
yum 趣味小游戏
- 牛说,yum -y install cowsay;
- 变字符,yum -y install figlet;
注:验证网络通畅 —— ping www.baidu.com