1. 程式人生 > 其它 >製作內網yum倉庫

製作內網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檔案