CentOS搭建本地局域网YUM源
时间:2015-06-06 03:53 来源:linux.it.net.cn 作者:IT
# 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
(责任编辑:IT)
# 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 (责任编辑:IT) |