CentOS7通過http方式搭建本地yum源

1.創建yum軟件保存目錄
*mkdir /var/www/html/yum/

這裏插一句
將磁盤上的iso文件掛載到一個目錄上的方法
用mount -o loop /mnt/
/1.iso /opt/cdrom 命令

2. 修改yum配置文件

先備份yum配置文件,修改yum配置文件中yum軟件包保存目錄並開啓rmp包緩存功能

1 [root@localhost ~]# cp /etc/yum.conf /etc/yum.conf.bak 
2 [root@localhost ~]# vim /etc/yum.conf
3 [main] 
4 #cachedir=/var/cache/yum/$basearch/$releasever
5 cachedir=/www/share/yum/$basearch/$releasever 
6 keepcache=1

3.安裝createrepo和http

createrepo 命令用於創建yum源(軟件倉庫),即爲存放於本地特定位置的衆多rpm包建立索引,描述各包所需依賴信息,並形成元數據
[root@localhost ~]# yum install createrepo httpd -y

4.創建http共享目錄,添加虛擬主機
vim /etc/httpd/conf.d/yum.conf #注意權限#

#http yum

Alias /yum /var/www/html/yum
<Directory "/var/www/html/yum">
Options Indexes FollowSymLinks
  IndexOptions NameWidth=* DescriptionWidth=* FoldersFirst
  IndexOptions SuppressIcon HTMLTable Charset=UTF-8 SuppressHTMLPreamble
  Order allow,deny
  Allow from all
  Require all granted
</Directory> 

在這裏插入圖片描述5. 啓動http服務
[root@localhost ~]# systemctl enable httpd.service && systemctl restart httpd.service
[root@localhost ~]# netstat -antp|grep ‘httpd’

瀏覽器訪問192.168.92.60/yum ,能訪問即正常。或者使用curl http://IP/yum 訪問

6.客戶端創建YUM軟件倉庫

vim /etc/yum.repos.d/local.repo

[base]
name=CentOS-$releasever
enabled=1
failovermethod=priority
baseurl=http://172.16.0.157/yum
gpgcheck=1
gpgkey=http://172.16.0.157/yum/RPM-GPG-KEY-CentOS-7

[updates]
name=CentOS-$releasever
enabled=1
failovermethod=priority
baseurl=http://172.16.0.157/yum
gpgcheck=1
gpgkey=http://172.16.0.157/yum/RPM-GPG-KEY-CentOS-7

[extras]
name=CentOS-$releasever
enabled=1
failovermethod=priority
baseurl=http://172.16.0.157/yum
gpgcheck=1
gpgkey=http://172.16.0.157/yum/RPM-GPG-KEY-CentOS-7

http://blog.sina.com.cn/s/blog_7c2ea9010102xcnu.html
7.在客戶端驗證,注意防火牆等安全策略和目錄權限

yum group list
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章