[Linux] httpd 自建 yum 安裝源

實驗拓撲:html

-----------------------------                                        ----------------------------apache

|server ip: 192.168.1.100|      < -------bridge--------> |client ip: 192.168.1.101|vim

-----------------------------                                        ----------------------------windows

思路:centos

1. [server端]確認安裝httpdbash

1
2
rpm -q httpd
httpd-2.2.15-29.el6.centos.i686

若沒有安裝, 進行安裝服務器

2. [server端]複製包文件到網頁文件目錄less

1
cp  /media/cdrom/Packages/ /var/www/html/Packages/

這裏我在網頁文件目錄下面創建了一個Packages文件來存放rpm包文件ide

是從光盤鏡像中拷貝來的測試

3. [server端]建立倉庫文件 createrepo /path

1
createrepo  /var/www/html/Packages/  #在該文件創建包文件的源數據文件

這樣咱們的rmp包服務器就準備完畢了, 下面能夠開始下載測試了

4. [client端]修改yum配置文件

打開另外一臺虛擬機, 固然兩臺機器首先要聯網的, 讓我ping一下先

1
2
3
4
5
ping  192.168.1.100
PING 192.168.1.100 (192.168.1.100) 56(84) bytes of data.
64 bytes from 192.168.1.100: icmp_seq=1 ttl=64  time =2.57 ms
64 bytes from 192.168.1.100: icmp_seq=2 ttl=64  time =0.396 ms
64 bytes from 192.168.1.100: icmp_seq=3 ttl=64  time =0.400 ms

yum repo配置文件路徑:

 

指定可用的yum倉庫 /etc/yum.conf, /etc/yum.repo.d/*.repo
配置文件格式: 有兩段組成, 相似windows的ini配置文件
[main] :主配置段
[repo] :倉庫配置段

yum repo配置文件的結構:

1
2
3
4
5
6
7
[reop_ID]  #注意repo_ID絕對不能與其餘配置文件中的ID重複
name=String  #倉庫名字
baseurl=http: //server/path/to/repo  #倉庫訪問路徑, 參見服務器的訪問方式:
enabled={1|0}  #是否啓用此倉庫, 默認啓用
gpgcheck={1|0}  #是否檢查包來源合法性, 完整性
gpgkey=  #gpg檢測時公鑰文件路徑, 能夠再本地,能夠再服務器上
cost=  #定義此倉庫的開銷, 默認爲1000, 越小越優先

 

OK! ping通了, 開始配置客戶機的yum repo配置文件, 把CentOS-Base.repo 中每一個倉庫都設置爲enabled=0,這樣咱們就不使用默認的倉庫, 若是 [base] 等 下面沒有enabled項目咱們手動添加enabled=0便可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
vim  /etc/yum .repos.d /CentOS-Base .repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
 
[base]
name=CentOS-$releasever - Base
mirrorlist=http: //mirrorlist .centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey= file : ///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0  #注意這裏設置爲0, 不使用的意思
#released updates 
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http: //mirrorlist .centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey= file : ///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0  #注意這裏設置爲0, 不使用的意思
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http: //mirrorlist .centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey= file : ///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0  #注意這裏設置爲0, 不使用的意思
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http: //mirrorlist .centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0  #注意這裏設置爲0, 不使用的意思
gpgkey= file : ///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http: //mirrorlist .centos.org/?release=$releasever&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0  #注意這裏設置爲0, 不使用的意思
gpgkey=
:wq  #保存後推出
vim  /etc/yum .repos.d /Httpd-test-Base .repo  #咱們來配置一個本身的repo配置文件,以下:
[httpd-192.168.1.100]
name= test
enabled=1
baseurl=http: //192 .168.1.100 /Packages/
gpgcheck=0
:wq  #保存而且退出
 
yum repolist  #看一下yum的repo列表, 若是跟下面輸出結果差很少,只要一個repo, 就設置好了
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
repo  id                                            repo name                          status
httpd-192.168.1.100                                test                                2,695
repolist: 2,695

 

 

5. [client端]安裝測試

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
yum  install  httpd
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package httpd.i686 0:2.2.15-29.el6.centos will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
====================================================================
  Package       Arch         Version                      Repository 
====================================================================
Installing:
  httpd         i686         2.2.15-29.el6.centos         httpd-192.1
 
Transaction Summary
====================================================================
Install       1 Package(s)
 
Total download size: 828 k
Installed size: 2.8 M
Is this ok [y /N ]: ^CExiting on user Command
[root@apache yum.repos.d] # yum install httpd
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package httpd.i686 0:2.2.15-29.el6.centos will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
====================================================================
  Package Arch   Version                 Repository             Size
====================================================================
Installing:
  httpd   i686   2.2.15-29.el6.centos    httpd-192.168.1.100   828 k
 
Transaction Summary
====================================================================
Install       1 Package(s)
 
Total download size: 828 k
Installed size: 2.8 M
Is this ok [y /N ]: y
Downloading Packages:
httpd-2.2.15-29.el6.centos.i686.rpm          | 828 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
   Installing : httpd-2.2.15-29.el6.centos.i686                  1 /1 
   Verifying  : httpd-2.2.15-29.el6.centos.i686                  1 /1 
 
Installed:
   httpd.i686 0:2.2.15-29.el6.centos                                 
 
Complete!

大功告成辛苦啦

相關文章
相關標籤/搜索