目录
概述
RPM包:RPM(原Red Hat Package Manager,现在是一个递归缩写)
由 Red Hat 公司提出,被众多 Linux 发行版所采用也称二进制( binary code)
优点:无需编译,可以直接使用
缺点:无法设定个人设置,开关功能
软件包示例(注意后缀):mysql-community-common-5.7.12-1.el7.x86_64.rpm
认识RPM包:zip - 3.0-11. el7. x86_64. rpm
zip :软件包名 3.0-11:版本号(Version) el7:发布版本(Release5/6/7) x86_64:系统平台(32/64) rpm:文件后缀
源码包:
缺点:source code 需要经过GCC,C++编译环境编译才能运行
优点:可以设定个人设置,开关功能
软件包示例:nginx-1.8.1.tar.gz
认识源码包:nginx包名 -1.8.1版本号 .tar.gz 压缩格式
一.PM包管理
1.YUM工具
简介:Yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器。
基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,
可以自动处理依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次下载、安装。
配置YUM仓库/YUM源
网络源:使用官方源
前提:一定要联网
设置虚拟机网络为NAT
打开Linux网络设置
打开浏览器上网测试
目的:使用国内厂商提供的软件包地址(如:http://alibaba.com/.)作为YUM的仓库。
使用阿里原作为YUM仓库
1 清理原先YUM库
[[email protected] ~]# yum install wget
mv /etc/yum.repos.d/* /tmp //
2 下载阿里源至yum库
[[email protected] ~]# wget http://mirrors.aliyun.com/repo/Centos-7.repo -O /etc/yum.repos.d/CentOS-Base.repo
3 更新YUM源
[[email protected] ~]# yum repolist //查看当前可用yum源
[[email protected] ~]# yum makecache //更新
EPEL
EPEL (Extra Packages for Enterprise Linux,企业版Linux的额外软件包)
下载epel配置文件
[[email protected] ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
重建缓存
[[email protected] ~]# yum makecache
Nginx:(配置文件)
Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务。
目的:通过查找官网了解构建官方源的原理。
第一步:找到提示
第二步:根据提示创建YUM配置文件
第三步: 查看服务器是否已经具备软件官方源。
[[email protected] ~]# vim /etc/yum.repos.d/nginx.repo
写入上图内容
[[email protected] ~]# yum list | grep nginx
使用YUM管理RPM包
全新安装:[[email protected] ~]# yum -y install httpd vsftpd
yum 主命令 -y 自动确认 install 安装 httpd 软件包1 vsftpd 软件包2
重新安装:当软件缺失文件,可尝试重新安装
[[email protected] ~]# yum -y reinstall httpd //reinstall 重新安装
升级安装::[[email protected] ~]# yum -y update httpd //升级一个程序httpd
[[email protected] ~]# yum -y update //升级所有程序
查询
查询YUM源 :[[email protected] ~]# yum repolist
查询HTTP程序:[[email protected] ~]# yum list httpd
卸载
卸载程序:[[email protected] ~]# yum -y remove httpd //remove移除,卸载软件包
查询工具和软件包的关系
1.当使用ifconfig命令失效时,却又不知道如何安装
2.使用provide查询命令的提供者进行安装。
3.查询:[[email protected] ~]# yum provides ifconfig
4.安装对应工具
2.RPM工具
前言:1.管理红帽系统/centos系统,rpm包的基本工具
2.YUM功能相同 3.优点不需要配置,直接使用
4.无法解决依赖关系 5.无法自行下载软件包
安装(i) :先找到安装包
mkdir /mnt/cdrom //创建挂载点
mount /dev/cdrom /mnt/cdrom //挂载光驱
[[email protected] ~]# yum install -y net-tools-2.0-0.25.20131004git.el7.x86_64
[[email protected] ~]# cd /mnt/cdrom/Packages
[[email protected] Packages]# ls wget-1.14-18.el7_6.1.x86_64.rpm //检查软件包是否存在
[[email protected] Packages]# rpm -ivh wget-1.14-18.el7.x86_64.rpm
-i 安装 v 可视 h 百分比
查询(q)[[email protected] Packages]# rpm -q wget //-q 查询
看到软件包的名字,就说明rpm -q查询成功,已经安装软件。
卸载(e)
卸载软件包:[[email protected] Packages]# rpm -evh wget-1.14-15.el7.x86_64
再次查询,发现已经卸载:[[email protected] Packages]# rpm -q wget-1.14-15.el7.x86_64
未安装软件包 wget-1.14-15.el7.x86_64
二.源码包管理
获得源码包:官方网站,可以获得最新的软件包
Apache: www.apache.org
Nginx: www.nginx.org
Tengine: tengine.taobao.org
实战案例
下载tengine
[[email protected] ~]# wget http://tengine.taobao.org/download/tengine-2.2.0.tar.gz //通过下载链接下载
准备编译环境如编译器
[[email protected] ~]# yum -y install gcc make zlib-devel pcre pcre-devel openssl-devel
[[email protected] ~]# useradd www
解压
[[email protected] ~]# [[email protected] ~]# tar xvf tengine-2.2.0.tar.gz
[[email protected] ~]# cd tengine-2.2.0
配置
[[email protected] tengine-2.2.0]#./configure --user=www --group=www --prefix=/usr/local/nginx //注意空格
编译
[[email protected] tengine-2.2.0]# make
安装
[[email protected] tengine-2.2.0]# make install
启动测试
可能之前的实验,安装过httpd服务。如果直接启动nginx会有冲突。请确保关闭httpd
# systemctl stop httpd
[[email protected] tengine-2.2.0]# /usr/local/nginx/sbin/nginx
[[email protected] tengine-2.2.0]# systemctl stop firewalld
使用浏览器访问本机的IP,http://127.0.0.1,如果能看到NGINX的网页,说明部署成功。