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
| # 1.先挂载CentOS-6.5-x86_64-bin-DVD1.iso
mount -o loop -t iso9660 /dev/cdrom /mnt/
rpm -Uvh /mnt/Packages/createrepo-0.9.9-18.el6.noarch.rpm
mkdir -p /data/www/centos/6/x86_64/
\cp -r /mnt/Packages/ /data/www/centos/6/x86_64/
cp /mnt/RPM-GPG-KEY-CentOS-* /data/www/centos/
umount /mnt
# 2.然后挂载CentOS-6.5-x86_64-bin-DVD2.iso
mount -o loop -t iso9660 /dev/cdrom /mnt/
\cp -r /mnt/Packages/ /data/www/centos/6/x86_64/
umount /mnt
# 3.创建仓库
createrepo /data/www/centos/6/x86_64/
# 4.启动nginx
cat > /etc/nginx/conf.d/yum.repo.conf << EOF
server {
listen 80;
server_name localhost;
root /data/www;
# 开启Nginx的目录文件列表
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
}
EOF
chmod 755 /data
chown -R nginx. /data/www
service nginx start
chkconfig nginx on
# 测试访问:http://192.168.20.210/centos/6/x86_64/
# 5.yum源配置
cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.bak
cat > CentOS-Base.repo << 'EOF'
[base]
name=CentOS-6 - Base - LAN
baseurl=http://192.168.20.210/centos/6/$basearch/
gpgcheck=1
gpgkey=http://192.168.20.210/centos/RPM-GPG-KEY-CentOS-6
EOF
# 6.验证
yum clean all
yum makecache
|