Yum本地源制作
环境准备
# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
更换阿里源
# rm -rf /etc/yum.repos.d/*
# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# yum makecache
安装web服务
# vim /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
# yum makecache
# yum install -y createrepo nginx
# mkdir -p /usr/share/nginx/html/RPMS
下载软件包及其依赖
### 方式一:使用CentOS默认的缓存方式,尽量选择刚安装的系统,保证缓存的依赖包完整
# vim /etc/yum.conf
keepcache=1
# yum clean all
# yum install httpd
# mkdir RPMS
# find /var/cache/yum/x86_64/7/ -name *rpm | xarg -i cp {} /usr/share/nginx/html/RPMS
### 方式二:使用yumdownloader,此方式对于依赖包很多的软件有时不是很准确
# yum install yum-utils
# yumdownloader --resolve --destdir=/usr/share/nginx/html/RPMS httpd
制作软件源
# createrepo /usr/share/nginx/html/RPMS/
### 开启外网访问
# firewall-cmd --zone=public --add-service=http
设置软件源
# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
# vim /etc/yum.repos.d/my.repo
[myrepo]
name=myrepo
baseurl=http://192.168.30.11/RPMS
enabled=1
gpgcheck=0