yum管理
各大镜像源:
阿里云:https://opsx.alibaba.com/mirror
清华源:https://mirrors.tuna.tsinghua.edu.cn/
华为源:https://mirrors.huaweicloud.com/
科大源:http://mirrors.ustc.edu.cn/
什么是yum
yum是RedHat以及CentOS中的软件包管理器,能够通过互联网下载以rpm结尾的包,并且安装,并可以自动处理依赖性关系,无需繁琐的一次次下载安装。 1.联网获取软件 2.基于RPM管理 3.自动解决依赖 4.命令简单好记 5.生产最佳实践
什么是yum源
理解为手机中的应用商店 yum源:镜像站,yum仓库,rpm仓库
要想成功的使用yum工具安装更新软件或系统,就需要有一个包含各种rpm软件包的repository(软件仓库),这个软件仓库我们习惯称之为yum源或者yum 仓库这个源可以是本地的也可以是网络的。
制作本地yum仓库
换源
base源:和镜像中的linux基础包差不多 epel源:一些拓展的包
# 本地yum储存位置(原本里面都是一些国外源)
ll /etc/yum.repos.d
# 1.删除本地yum源
rm -fr /etc/yum.repos.d/*
-#安全点的方式打包(备份)
gzip /etc/yum.repos.d/*
------这里使用的是阿里源:https://opsx.alibaba.com/mirror -----------------
# 2.更换base源
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
#或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
# 3.更换epel源
wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
yum开启缓存(可以不开)
vim /etc/yum.conf
[main]
keepcache=0--改成-->1
#下载完东西后(如tree)
# 加载yum缓存(就这里加载一次就行了)
yum makecache
# 查看本地缓存包
ll /var/cache/yum/x86_64/7/updates/packages
yum实践
yum查询
# 查看yum仓库中所有可以安装的包
yum list
# 过滤
[root@web02 ~]# yum list | grep vim
包名 版本号 发布次数 系统平台 隶属那个源
vim-common.x86_64 2:7.4.629-8.el7_9 @updates
neovim.x86_64 0.3.0-2.el7 epel
protobuf-vim.x86_64 2.5.0-8.el7 base
# 查看仓库中所有包的详细信息
[root@web02 ~]# yum info
yum安装
# yum安装方法
-#本地安装
yum localinstall -y 包名
yum localinstall -y vim-enhanced-7.4.629-8.el7_9.x86_64.rpm
-#yum源安装
yum install -y 包名(vim / wget /lrzsz)
-#网站上安装
yum install -y https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-java-gateway-5.0.26-1.el7.x86_64.rpm
# 自动解决依赖的前提,在你的yum源中都要有该软件的依赖
-#选项
-y 免交互
PS-ef 查看进程 kill 杀死进程
yum重装
yum reinstall -y
恢复最初配置文件的作用
yum更新
# 检查所有可以更新的包
yum check-update
# 更新
yum update -y 包名
yum卸载
yum remove -y 包名
yum erase -y 包名
源码安装nginx
linux中软件的安装方式 :
安装包 |
安装方式 |
rpm包 |
rpm yum |
源码 |
编译安装 |
二进制包 |
免安装 |
获取源码包
想要什么源码包,就去他的官网(nginx.org)!!!!!
# nginx官网,下载源码包
wget http://nginx.org/download/nginx-1.20.2.tar.gz
# 解压
tar xf nginx-1.20.2.tar.gz
--------# 总解决方法--------------------------------------------------------------------------------------
yum install -y openssl-devel pcre-devel gcc gcc-c++ glibc
# 再次生成:./configure --prefix=/opt/nginx-1.20.2 --with-http_ssl_module --withhttp_stub_status_module
--------------------------------------------------------------------------------------------------------
# 直接生成会有报错
./configure --prefix=/opt/nginx-1.20.2 --with-http_ssl_module --withhttp_stub_status_module
# 报错1 缺少c语言
./configure: error: C compiler cc is notfound
## 解决方法
yum install gcc gcc-c++ glibc -y
# 报错2 缺少pcre依赖
./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 install -y pcre-devel
# 报错3 缺少openssl依赖
/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 install -y openssl-devel
-----------------------------------------------------------------------------------------------------------
# 编译(为了让系统能识别你的代码,并且把刚才指定的功能和路径编辑到源码中)
make
# 安装
make install
# 做软连接
ln -s /opt/nginx-1.20.2/ /opt/nginx
# 增加环境变量(是为了把启动方式写到环境变量里)(目的是为了让他可以通过文件名执行)
vim /etc/profile.d/nginx.sh
export PATH="$PATH:/opt/nginx/sbin" (/opt/nginx是软连接路径,其实是安装路径)
# 生效环境变量
source /etc/profile
# 启动nginx
nginx
# 关闭防火墙
systemctl stop firewalld
# 关闭selinux(setenforce 0)
vim /etc/sysconfig/selinux
selinux=disabled
私有yum仓库
# 让原本的源失效(把原有的仓库打包)
gzip /etc/yum.repos.d/*
# 创建一个本地仓库目录
mkdir /local_yum/
# 挂载
mount /dev/cdrom /local_yum/
df -h 检查一下
# 添加一个.repo结尾的源文件
vim whh.repo
[whh]
name=wojiushiwhh
baseurl=file:///local_yum
gpgcheck=0
enable=1
# 重新加载缓存
yum makecache
制作企业级yum仓库
# 安装vsftpd服务,让该机器能够用变成网络服务
yum install -y vsftpd
# 启动服务
systemctl start vsftpd
vim /etc/sysconfig/selinux
# 关闭selinux
vim /etc/sysconfig/selinux
SELINUX=disable
# 在ftp目录下创建一个base目录
mkdir /var/ftp/pub/base
# 挂载光盘
mount /dev/cdrom /mnt/
# 拷贝所有的包
cp /mnt/Packages/* /var/ftp/pub/base/
# 安装仓库制作命令
yum install -y creatrepo
# 访问ftp://域名或IP/pub/base
拓展
yum用法