Linux软件管理

本文详细介绍了Linux系统下使用RPM和YUM管理软件的方法,包括安装、查询、卸载和更新等操作。RPM用于管理二进制包,而YUM则是基于RPM的包管理器,提供了更方便的处理依赖关系的功能。文章还提到了源码包的管理和安装过程,强调了在安装过程中可能遇到的依赖问题及其解决办法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

指令:


yum -y install:全新安装 rpm -ivh:安装rpm包 --nodeps(忽略依赖关系)--force(强制安装软件包)--nosignature
yum -y reinstall:重新安装 rpm -q:查询指定包是否安装 -qa(查询所有已安装)-ql(查询安装的文件)
yum -y update(更新):升级安装 -qf(查询该文件属于哪个rpm包) -qi (查询包的information)
yum -y groupinstall:组安装 -qc (查询某个包安装的配置文件) -qd (查安装的帮助文档)
yum list(列表):查询程序 rpm -e :删除安装程序
带@ 是已经安装的。
yum info(信息):查询程序详细信息 systemctl(系统CTL) start(开始):启动
yum group list、info:查询程序组信息 systemctl status(地位,状态):查看
yum -y remove(去除):卸载程序 systemctl stop(停止,中断) :停止
yum -y groupremove:卸载组程序
yum provides(提供):通过命令查找包
yum history(历史命令允许用户查看过去
事务中发生的事情)
wget:非交互式网络下载器。
*********************************************************************************************************************************************************************************************
概述:
一、软件的类型
A. 二进制包 已编译 mysql-community-common-5.7.12-1.el7.x86_64.rpm
B. 源码包 需要编译 nginx-1.8.1.tar.gz
RPM Package Manager(原Red Hat Package Manager,现在是一个递归写)
注意: 不管是源码包,还是二进制包,安装时都可能会有依赖关系!

RPM包管理

 

YUM:


1.YUM源(YUM仓库):
1.本地源:安装光盘 2.官方源:
目的:通过系统光盘安装软件(90%都有) 百度 阿里yum
1 删除YUM库 下载阿里源(epel)
[root@tianyun ~]# rm -rf /etc/yum.repos.d/* 更新yum源:yum makecache
2挂载安装光盘(临时):
[root@tianyun ~]# mount /dev/cdrom /mnt
3编写配置文件。
[root@tianyun ~]# vim /etc/yum.repos.d/dvd.repo
[dvd]
name=dvd
baseurl=file:///mnt/
gpgcheck=0

4 使用YUM 安装和卸载程序即可。
[root@tianyun ~]#yum install -y httpd
[root@tianyun ~]#systemctl start httpd
[root@tianyun ~]#systemctl stop firewalld
5.使用客户机访问即可
打开浏览器,输入网站服务器的IP地址。
2.使用YUM管理RPM包:
查看可用仓库:
[root@tianyun ~]# yum clean all //清空缓存及其它文件(可以通过清理nginx.rpm观察)
[root@tianyun ~]# yum makecache //重建缓存
[root@tianyun ~]# yum repolist //查询可用的仓库
1.安装
全新安装:yum install
# yum -y install httpd vsftpd *vnc
# yum -y install https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
//从互联网安装
重新安装: yum reinstall
# yum -y reinstall httpd //有损坏才重新部署修复。(尝试损坏httpd程序)
升级安装: yum update
# yum -y update httpd
# yum -y update //系统更新,请在安装系统后立即执行。(实验室请不要执行)
# yum -y update kernal //升级内核。重启就看到了。(已更新)
组安装: yum groupinstall
# yum -y groupinstall mariadb
2.查询
yum list or yum info(详细信息)
查询HTTP程序 查询类似vnc程序 查询安装过程序
# yum list httpd # yum list *vnc* # yum list installed
带@ 是已经安装的。
查询HTTTP程序的详细信息 查询程序组 查询程序组的详细信息
# yum info httpd # yum group list # yum group info mariadb(注意您的系统语言。)
3.卸载
卸载程序
[root@tianyun ~]# yum -y remove mysql-server
卸载程序组
[root@tianyun ~]# yum -y groupremove mysql-server
history
# yum history
# yum history info 4
# yum history undo 4
扩展查询:yum provides(通过命令找包)

RPM


安装(i)
路径
rpm -ivh local_path
rpm -ivh url_path
示例
rpm -ivh https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
必须在线
准备工作:下载软件包



额外选项
--nodeps //忽略依赖关系
1.发现有依赖关系
[root@localhost Packages]# rpm -ivh wireshark-1.10.14-14.el7.x86_64.rpm
错误:依赖检测失败:
libcares.so.2()(64bit) 被 wireshark-1.10.14-14.el7.x86_64 需要
libsmi.so.2()(64bit) 被 wireshark-1.10.14-14.el7.x86_64 需要

2.放弃某些功能时
[root@localhost Packages]# rpm -ivh wireshark-1.10.14-14.el7.x86_64.rpm --nodeps
准备中... ################################# [100%]
正在升级/安装...
1:wireshark-1.10.14-14.el7 ################################# [100%]
--force //强制安装软件包
rpm 无法将已经安装的软件包,重复安装。
比如你装过这个rpm的版本1,如果你想装这个rpm的版本2,就需要用--force强制安装
--nosignature //忽略签名
1安装互联网的软件包时会提示没有签名
[root@localhost ~]# rpm -ivh mysql57-community-release-el7-9.noarch.rpm
警告:mysql57-community-release-el7-9.noarch.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
软件包 mysql57-community-release-el7-9.noarch 已经安装
[root@localhost ~]#

2.安装时可以添加--nosignature,从而忽略签名
[root@localhost ~]# rpm -ivh mysql57-community-release-el7-9.noarch.rpm --force --nosignature
准备中... ################################# [100%]
正在升级/安装...
1:mysql57-community-release-el7-9 ################################# [100%]

注意
RPM包安装信息存储到本地RPM数据库中。。。
查询(q)
从本地的rpm数据库
[root@tianyun ~]# rpm -q wireshark //查询指定包是否安装
[root@tianyun ~]# rpm -qa |grep wireshark //在所有已经安装的包中查询wireshark
[root@tianyun ~]# rpm -ql wireshark //查询wireshark安装的文件
[root@localhost ~]# rpm -qf /usr/share/wireshark/ws.css //查询该文件属于哪个rpm包(which)
[root@tianyun ~]# rpm -qi wireshark //查询包的information
[root@tianyun ~]# rpm -qc httpd //查询某个包安装的配置文件(无)
[root@tianyun ~]# rpm -qd httpd //查安装的帮助文档
从rpm套件中查询(未安装)qi------p---package
卸载(e)
[root@localhost ~]# rpm -q httpd
httpd-2.4.6-67.el7.centos.6.x86_64
[root@localhost ~]# rpm -e httpd
[root@localhost ~]# rpm -q httpd
未安装软件包 httpd

源码包管理


1. 获得源码包途径
官方网站,可以获得最新的软件包
Apache: www.apache.org
Nginx: www.nginx.org
Tengine: tengine.taobao.org
2. 实战案例
部署Tengine /Nginx服务器/WEB服务器
1. 下载源码包,准备软件包
2.准备编译环境如编译器gcc、make
# yum -y install gcc make zlib-devel pcre pcre-devel openssl-devel
(pcre: 支持正则表达式,地址重写rewrite)

3.解压
# useradd www
# tar xvf tengine-2.2.0.tar.gz
# cd tengine-2.2.0
4.配置
./configure \
--user=www \
--group=www \
--prefix=/usr/local/nginx \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_ssl_module \
--with-pcre
5.编译
# make
6.安装
# make install

7启动测试
# /usr/local/nginx/sbin/nginx //启动nginx服务器
# systemctl stop firewalld
看到网页,说明部署成功。
源码安装错误:
error1:
error1:
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
解决方案:
# yum -y install zlib-devel

or install the zlib library into the system,
error2:
error2:
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.
解决方案:
# yum -y install openssl-devel

error3:
error3:
checking for C compiler ... not found
./configure: error: C compiler cc is not found
解决方案:
# yum -y install gcc gcc-c++ make

error4:
error4:
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
解决方案:
# yum -y install pcre-devel

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值