linux——centos 的软件管理

linux——centos 的软件管理

yum 查看(可用仓库) 安装 卸载 history
RPM 安装 查询 卸载
源码包
软件的类型
二进制包(.rpm) 已编译mysql-community-common-5.7.12-1.el7.x86_64.rpm
原Rad Hat公司推出的软件包管理器,能提供商业服务
Ubuntu/Debian(DPKG)也在编译软件包,是自由形式,不能提供服务
优点:安装速度快 缺点:不能调整功能。
源码包(tar.gz)需要编译nginx-1.8.1.tar.gz

yum源(yum仓库) 本地源 官方源
(了解)本地源目的:通过光盘安装软件(90%都有)
目的:使用厂商提供的软件包作为YUM的仓库
官方源:
阿里yun
Base/Extras/Updates 默认(国外源)
rm -rf /etc/yum.repos.d/* 删除原先源
适用于Red Hat7/Centos7 :wget http://mirrors.aliyun.com/repo/Centos-7.repo -O /etc/yum.repos.d/CentOS-Base.repo
下载阿里源
yum makecache 更新yum源

EPEL: 为“红帽系”的操作系统提供额外的软件包,适用于RHEL、CentOS和Scientific Linux.
用于RHEL6系列:wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm

MySQL :
适用于Red Hat Linux7 :https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm

Nginx:(配置文件)
[root@localhost ~]# vim /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

使用YUM管理RPM包(推荐使用yum)
安装:
全新安装 #yum -y install httpd vsftpd *vnc
重新安装 #yum -y reinstall httpd(尝试损坏httpd程序)
#yum -y update httpd
升级安装 #yum -y update系统更新,请在安装系统后立即执行。(实验室请不要执行)
#yum -y update kernal (升级内核,重启后看到)
组安装 #yum -y group install mariadb

查询:
查询HTTP程序 #yum list httpd(带@是已安装)
查询类似vnc程序#yum list *vnc*
查询HTTP程序的详细信息 # yum info httpd
查询程序组 #yum group list
查询程序组的详细信息 #yum group info mariadb

卸载:
卸载程序 #yum -y remove mysql-server
卸载程序组 #yum -y groupremove mysql-server

history:
# yum history
# yum history info 4
# yum history undo 4


RPM
安装 :
路径: rpm -ivh local_path
rpm -ivh url_path (必须在线)
示例:rpm -ivh https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
额外选项
-nodeps //忽略依赖关系 [root@localhost Packages]# rpm -ivh wireshark-1.10.14-14.el7.x86_64.rpm
错误:依赖检测失败:
1.发现有依赖关系
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%]

查询(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:
./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:
./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:
checking for C compiler ... not found
./configure: error: C compiler cc is not found
解决方案:
# yum -y install gcc gcc-c++ make

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

安装源码的技巧:
README
INSTALL

猜你喜欢

转载自www.cnblogs.com/chunjianghuayueye369/p/9028172.html