Centos7-软件包的管理与安装

1.软件包介绍

1.1软件包类型

  • rpm 二进制包 ====》已经使用gcc编译后的
  • tar源码包====》需要编译

2.rpm包管理

2.1使用介绍

  • rpm工具使用分为安装、查询、验证、更新、删除等操作
  • rpm包格式说明:
[root@localhost ~]# ll /mnt/Packages/zsh-5.0.2-14.el7.x86_64.rpm 
-r--r--r--. 3 root root 2488816 Nov 25  2015 /mnt/Packages/zsh-5.0.2-14.el7.x86_64.rpm
zsh	   软件名    
5     主版本号 
0      次版本号
2      修订次数,指定是第几次修改bug
14	   release(第几次发布,指的是简单的修改参数)
el7	   操作系统版本
x86_64 64位系统
  • 命令格式:
rpm [参数] 软件包
  • 参数:
安装:
-i 是install的意思,安装软件包
-v 显示附加信息,提供更多详细信息
-V 校验,对已安装的软件进行校验
-h --hash 安装时输出###标记
查询
-q 查询,一般跟下面的参数配合使用
-a 查询所有已安装的软件包
-f 系统文件名(查询系统文件属于哪个安装包)
-i 显示已安装的rpm软件包信息
-l 查询软件包文件的安装位置
-p 查询未安装软件包的相关信息
-R 查询软件包的依赖性
卸载
-e erase
--nodeps 忽略依赖
升级
-U 一般配合vh使用

2.2安装

[root@localhost ~]# cat /etc/shells 
/bin/sh
/bin/bash
/sbin/nologin
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin
[root@localhost ~]# rpm -ivh /mnt/Packages/zsh-5.0.2-14.el7.x86_64.rpm(这里接上的是本地路径,可以指定网上的rpm)
Preparing...                          ################################# [100%]
Updating / installing...
   1:zsh-5.0.2-14.el7                 ################################# [100%
[root@localhost ~]# tail -1 /etc/shells 
/bin/zsh

2.3查询

查看是安装
[root@localhost ~]# rpm -qa zsh
zsh-5.0.2-14.el7.x86_64
查看命令属于哪一个安装包
[root@localhost ~]# which zsh
/usr/bin/zsh
[root@localhost ~]# rpm -qf /usr/bin/zsh
zsh-5.0.2-14.el7.x86_64
查看安装包的生成文件位置
[root@localhost ~]# rpm -ql zsh-5.0.2-14.el7.x86_64 |tail -5 
/usr/share/zsh/5.0.2/functions/zstyle+
/usr/share/zsh/5.0.2/functions/ztodo
/usr/share/zsh/5.0.2/scripts
/usr/share/zsh/5.0.2/scripts/newuser
/usr/share/zsh/site-functions
查看安装包的详细信息或作用
[root@localhost ~]# rpm -qi zsh-5.0.2-14.el7.x86_64 |tail -5
shell and as a shell script command processor.  Zsh resembles the ksh
shell (the Korn shell), but includes many enhancements.  Zsh supports
command line editing, built-in spelling correction, programmable
command completion, shell functions (with autoloading), a history
mechanism, and more.
查看命令是否被修改
[root@localhost ~]# rpm -V findutils-4.5.11-5.el7
[root@localhost ~]# rpm -Vf /usr/bin/find        
[root@localhost ~]# echo "aa" >>/usr/bin/find
[root@localhost ~]# rpm -Vf /usr/bin/find    
S.5....T.    /usr/bin/find
[root@localhost ~]# rpm -V findutils-4.5.11-5.el7
S.5....T.    /usr/bin/find
2.4卸载升级
[root@localhost ~]# rpm -e zsh
[root@localhost ~]# rpm -Uvh /mnt/Packages/rsyslog-7.4.7-12.el7.x86_64.rpm 
Preparing...                          ################################# [100%]
        package rsyslog-7.4.7-12.el7.x86_64 is already installed

3.yum管理软件包

3.1yum介绍

  • yum是一个前端软件包管理器。基于rpm包管理,能够从指定的服务器自动下载rpm包并且安装,可以自动处理依赖关系,并且一次安装所有依赖的软件包,无需繁琐的一次次下载、安装。yum提供了查找、安装、删除某一个、一组甚至全部软件包的命令,而且命令简介而又好记。
  • 常用操作:
yum install -y httpd #安装软件包
yum update httpd #升级软件包,改变软件设置和系统设置,系统版本内核都升级
yum install upgrade #升级软件包,不改变软件设置和系统设置,系统版本内核都升级
yum info httpd #查询包
yum provides /usr/bin/find #查询命令属于哪一个包
yum remove -y httpd #卸载
yum search httpd #按关键字搜索包
yum clan all #清除缓存
yum makecache #生成缓存
yum repolist #查看可用的yum源
yum grouplist #列出可用组

3.2配置本地yum源

[root@localhost ~]# mount /dev/cdrom /mnt
mount: /dev/sr0 is write-protected, mounting read-only
[root@localhost ~]# cat /etc/yum.reps.d/Centos7.repo
[centos7]#yum源名称,在本服务器上唯一
name=centos#源的描述信息
baseurl=file:///mnt源的路径,可以使用ftp.http
enabled=1#启动yum,0为不启用
gpgcheck=0#不使用使用公钥检验rpm的正确性,1为使用。

3.3配置网络yum

下载阿里云
[root@localhost ~]# wget -O /etc/yum.repos.d/Centos-7.repo http://mirrors.aliyun.com/repo/Centos-7.repo 

4.tar源码包管理

4.1源码安装三把斧

./configure 
#可以指定安装路径,启用或者禁用功能等,最终生成makefile
make 
#按Makefile文件编译
make install
#按Makefile定义的文件路径安装
make clean
#清除上一次make命令所产生的object文件,要重新执行
configure时,需要执行make clean。

4.2以简单安装nginx为例

下载nginx tar包
[root@localhost ~]# wget http://nginx.org/download/nginx-1.12.2.tar.gz
[root@localhost ~]# ll nginx-1.12.2.tar.gz 
-rw-r--r--. 1 root root 981687 Oct 21  2018 nginx-1.12.2.tar.gz
解压安装包
[root@localhost ~]# tar xf nginx-1.12.2.tar.gz 
[root@localhost nginx-1.12.2]# ./configure 
[root@localhost nginx-1.12.2]# make && make install
不指定路径默认编译的路径
[root@localhost ~]# ls /usr/local/nginx/
conf  html  logs  sbin

4.3解决编译依赖问题

编译nginx未安装依赖库报错
./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.
缺少的库有
PCRE library
解决方法1:
进入/mnt/Packages
[root@localhost Packages]# ls pcre*
pcre-8.32-15.el7.x86_64.rpm  pcre-devel-8.32-15.el7.x86_64.rpm
[root@localhost Packages]# ls *pcre*
pcre-8.32-15.el7.x86_64.rpm  pcre-devel-8.32-15.el7.x86_64.rpm
[root@localhost Packages]# ls *pc* #上两步找不到,则匹配一半
[root@localhost Packages]# ls *re*
安装
[root@localhost Packages]# rpm -ivh  pcre-devel-8.32-15.el7.x86_64.rpm###一般只需要安装名字带有devel的包
解决方法2:
[root@localhost ~]# yum search pcre

5.总结

  • rpm+yum:方便,软件版本低,稳定性好,管理方便,性能稍差
  • 源码编译安装:麻烦,软件版本新,可以定制,稳定性稍差,管理稍差,性能好。
  • 3
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值