搭建私有软件源

软件源服务器:

先安装好nginx服务或httpd服务

修改nginx配置文件

vim /usr/local/nginx/conf/nginx.conf

在http项中添加下列参数

autoindex on; #开启nginx目录浏览功能

autoindex_exact_size off; #文件大小从KB开始显示

autoindex_localtime on; #显示文件修改时间为服务器本地时间

charset utf-8,gbk,gb2312; # 避免中文乱码

安装createrepo

yum install -y createrepo

创建一个站点用于存放rpm包 以nginx为例
创建目录站点

mkdir -p /usr/local/nginx/html/yum

使用createrepo建立或更新索引

createrepo /usr/local/nginx/html/yum/

客户端使用软件源
创建软件源\
vim /etc/yum.repos.d/myyum.repo
配置文件如下

[test]
name=yum test
baseurl=https:/zelt.cn
enabled=1
gpgcheck=0
gpgkey=http://zelt.cn/RPM-GPG-KEY-TESTREPO
#参数说明
#enabled=1 为启用 改为0关闭
#gpgcheck=0 key配对开关 参数为1开 0关