制作内网yum仓库

nginx官方源

cat > /etc/yum.repos.d/nginx.repo << 'EOF'

[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

EOF
yum makecache fast -y

需要的软件

createrepo
nginx


yum install nginx createrepo -y

配置索引模块

rm -rf /etc/nginx/conf.d/*
[root@web-7 /etc/nginx/conf.d]# 

cat > /etc/nginx/conf.d/yum.conf << 'EOF'
server {
 listen 80;
 server_name yum.linux08.com;
 location / {
 autoindex on;
 autoindex_exact_size off;
 autoindex_localtime on;
 autoindex_format html;
 charset utf-8,gbk;
 root /data/yum;
 index index.html index.htm;
 }
}

EOF


安装createrepo


[root@web-7 /etc/nginx/conf.d]# yum install createrepo -y

准备软件仓库

[root@web-7 /etc/nginx/conf.d]# 

yum install -y --downloadonly --downloaddir=/data/yum vim

生成yum元数据

[root@web-7 /etc/nginx/conf.d]# cd /data/yum
[root@web-7 /etc/nginx/conf.d]# createrepo /data/yum
[root@web-7 /etc/nginx/conf.d]# createrepo --update /data/yum

客户端生成本地源

mv /etc/yum.repos.d/* /tmp

cat > /etc/yum.repos.d/local.repo << 'EOF' 
[local]
name=local
enable=1
gpgcheck=0
baseurl=http://10.0.0.149
EOF


添加阿里源(可选)

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
sed -i '/aliyuncs/d' /etc/yum.repos.d/CentOS-Base.repo
yum makecache fast
ll /etc/yum.repos.d/

客户端测试安装

[root@m-61 /etc/yum.repos.d]# yum makecache fast 
[root@m-61 /etc/yum.repos.d]# yum search nginx
[root@m-61 /etc/yum.repos.d]# yum install nginx 


更改本地hosts文件

posted @   ngwei  阅读(85)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
· 张高兴的大模型开发实战:(一)使用 Selenium 进行网页爬虫
点击右上角即可分享
微信分享提示