Linux installation and management program-rpm, yum installation
Linux application basics
The relationship between applications and system commands
Character | System command | application |
---|---|---|
File location | Generally in the /bin and /sbin directories, or shell internal commands | Usually in the /usr/bin and /usr/sbin directories |
The main purpose | Complete the basic management of the system, such as IP configuration tools | Complete other relatively independent auxiliary tasks, such as a web browser |
Applicable environment | Generally only run in the character operation interface | According to actual needs, some programs can be run in the graphical interface |
Run format | Generally include command words, command options and command parameters | There is usually no fixed execution format |
Directory structure of a typical application
file type | Save directory |
---|---|
Common executive file | /usr/bin |
Server execution program file and management program file | /usr/sbin |
Application configuration file | /etc |
Log file | / var / log |
Application Reference Document File | /usr/share/doc |
Application man page file | /usr/share/man |
Common package types
file type | Save directory |
---|---|
RPM package | The extension is ".rpm" |
DEB software package | The extension is ".deb" |
Source code package | Generally, it is a compressed package in the format of ".tar.gz", ".tar.bz2", etc. |
Contains the original code of the program | |
Green free installation package | The extensions of the software packages vary, mostly in TarBall format; the compiled executable program files are provided in the compressed package; the files after unzipping the compressed package can be used directly |
RPM package management tool
Red-Hat Package Manager
Proposed by Red Hat, adopted by many Linux distributions.
Establish a unified database file.
Detailed record of software package installation, uninstallation and other changes.
Automatic analysis of software package dependencies
RPM package
Software material reference: http://www.rpm.org
General naming format:
bash-4.1.2-15.el6_4.x86_64.rpm
bash software name-4.1.2 version number-15 release times-x86_64 hardware platform-rpm extension name
Format of the rpm command
The rpm command can realize almost all the management functions of the RPM software package
Execute "man rpm" command to get detailed help information about
rpm command. rpm command function
Query and verify the relevant information of the RPM software package
Install, upgrade, uninstall the RPM software package,
maintain RPM database information and other comprehensive management operations
Query RPM package information
Query information about installed RPM software
rpm -q[子选项] [软件名]
Common options
-q | Query whether the specified software has been installed |
---|---|
-qi | Display the detailed information of the specified software installed |
-ql | Display the file list of the specified software that has been installed |
-qc | List the installed configuration files of the specified software |
-qd | List the location of the package documentation of the specified software that has been installed |
-qR | List the dependent software packages and files of the installed specified software |
-qf | Query which installation package the specified software has been installed belongs to |
-qa | Display a list of all software installed in rpm mode in the current system |
-qa | grep -i postfix |
Query the information in the RPM package file that is not installed
rpm -qp[子选项] RPM包文件
Common options
-qpi | Query the detailed information of the specified software package |
---|---|
-qpl | Query the file list of the specified software package |
-qpc | Query the configuration file of the specified software package |
-qpd | Query the location of the package documentation for the specified package |
Install, upgrade, and uninstall RPM software packages
Install or upgrade RPM software
rpm [选项] RPM包文件 ...
Common options
-i | Install a new RPM package |
---|---|
-U | Upgrade a software package, if it has not been installed, install it |
-F | Upgrade a software package, if it has not been installed, then abandon the installation |
-h | In the process of installing or upgrading the software package, the installation progress will be displayed with "#" |
-v | Display detailed information during software installation |
–force | 强制安装某个软件包,比如要安装版本更旧的软件包 |
-e | 卸载指定名称的软件包 |
–nodeps | 在安装或升级、卸载一个软件包时,不检查与其他软件包的依赖关系 |
维护RPM数据库
重建RPM数据库
当 RPM 数据库发生损坏,可通过 重建RPM数据库 修复
[root@localhost ~]# rpm --rebuilddb
或者
[root@localhost ~]# rpm --initdb
导入验证公钥
在没有导入用于数字签名验证的公钥文件之前,安装光盘中的一部分RPM软件包时会报错。需要向RPM数据库中导入位于光盘根目录下的公钥文件
[root@localhost ~]# rpm --import /media/cdrom/RPM-GPG-KEY-CentOS-7
解决软件包依赖关系方法
安装有依赖关系的多个软件时
被依赖的软件包需要先安装
可同时指定多个 .rpm 包文件进行安装
卸载有依赖关系的多个软件时
依赖其他程序的软件包需要先卸载
可同时指定多个软件名进行卸载
忽略依赖关系
结合“–nodeps”选项,但可能导致软件异常
源代码编译概述
使用源代码安装软件的优点:
获得最新的软件版本,及时修复bug
根据用户需要,灵活定制软件功能
应用场景使用简单举例:
安装较新版本的应用程序时
当前安装的程序无法满足需要时
需要为应用程序添加新的功能时
Tarball封包
.tar.gz和.tar.bz2格式居多
软件素材参考:http://sourceforge.net
完整性校验
md5sum校验工具
[root@localhost ~]# md5sum httpd-2.4.25.tar.gz
24fb8b9e36cf131d78caae864fea0f6a httpd-2.4.25.tar.gz
确认源代码编译环境
需安装支持C/C++程序语言的编译器,如:gcc、gcc-c++、make、……
配置本地yum源仓库
先配置本地yum源仓库
mount /dev/cdrom /mnt/ #把光盘挂载到/mnt目录下
cd /etc/yum.repos.d/
mkdir repos.bak
mv * repos.bak
vim local.repo
[local] #仓库类别
name=local #仓库名称
baseurl=file:///mnt #指定URL 访问路径为光盘挂载目录
enabled=1 #开启此yum源,此为默认项,可省略
gpgcheck=0 #不验证软件包的签名
yum clean all && yum makecache #删除yum缓存并更新
yum常用的操作命令:
yum -y install 软件名 #安装、升级软件包,“-y”选项表示自动确认
yum -y remove 软件名 #卸载软件包,可自动解决其依赖关系
yum -y update 软件名 #升级软件包
yum list #查询软件包列表
yum list installed #查询系统中已安装的软件包
yum list available #查询仓库中尚未安装的软件包
yum list updates #查询可以升级版本的软件包
yum info 软件名 #查询软件包的描述信息
yum info httpd
yum search [all] 关键词 #根据某个关键词来查找相关的软件包
yum search all httpd
yum -y install 软件名 | 安装、升级软件包,“-y”选项表示自动确认 |
---|---|
yum -y remove 软件名 | 卸载软件包,可自动解决其依赖关系 |
yum -y update 软件名 | 升级软件包 |
yum list | 查询软件包列表 |
---|---|
yum list installed | 查询系统中已安装的软件包 |
yum list available | 查询仓库中尚未安装的软件包 |
yum list updates | 查询可以升级版本的软件包 |
yum info httpd
yum info 软件名 | 查询软件包的描述信息 |
---|
yum search all httpd
yum search [all] 关键词 | 根据某个关键词来查找相关的软件包 |
---|
yum whatprovides netstat
yum whatprovides 命令 | 查询命令属于哪个软件包 |
---|
使用yum方式进行安装
yum install -y gcc gcc-c++ make
编译安装的基本过程
第一步:tar 解包
tar zxvf/jxvf xxx.tar.gz/xxx.tar.bz2 -C 目标路径
第二步:配置软件模块(安装路径、开启或关闭模块功能、管理服务进程的用户设定)
./configure --prefix=目标路径(此软件安装到哪里去)
第三步:编译(将源代码转换为可执行的程序)
make
第四步:安装
make install
tar解包
习惯上将软件包释放到/usr/src/目录;解包后的源代码文件位置 /usr/src/软件名-版本号/
解包示例
[root@localhost ~]# tar zxf httpd-2.4.25.tar.gz -C /usr/src/
解压源代码包,并指定释放目录
./configure配置
使用源码目录中的configure脚本;执行“./configure --help”可查看帮助
典型的配置选项:
–prefix=软件安装目录
解包示例
[root@localhost ~]# cd /usr/src/httpd-2.4.25/
[root@localhost httpd-2.4.25]# ./configure --prefix=/usr/local/apache
若不指定任何配置选项,将采用默认值
make编译与安装
编译
执行make命令
安装
执行make install命令
命令示例
[root@localhost httpd-2.4.25]# make
[root@localhost httpd-2.4.25]# make install
测试、应用、维护软件
使用前
[root@localhost httpd-2.4.25]# vim /usr/local/apache/conf/httpd.conf
启动Apache
[root@localhost httpd-2.4.25]# /usr/local/apache/bin/apachectl start
运行 lynx 127.0.0.1查看本机Apache运行状态