#局域网yum仓库搭建-http方式和ftp方式
[[email protected] ~]# uname -a
Linux YUM01 2.6.32-696.23.1.el6.x86_64 #1 SMP Tue Mar 13 22:44:18 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[[email protected] ~]# cat /etc/redhat-release
CentOS release 6.9 (Final)
http服务器端设置
[[email protected] ~]# yum install -y createrepo httpd #安装createrepo和httpd
[[email protected] ~]# chkconfig httpd on #开启httpd服务
[[email protected] ~]# service httpd start #启动httpd服务
[[email protected] ~]# mkdir -p /yumserver/centos6.9/Packages #创建安装包目录
ftp服务器端设置
[[email protected] ~]# chkconfig vsftpd on #开启httpd服务
[[email protected] ~]# service vsftpd start #启动httpd服务
修改ftp用户的登录属性:
[[email protected] ~]#vi /etc/passwd
ftp:x:14:50:FTP User:/yumserver:/sbin/nologin #将用户目录修改为/yuserver目录
#ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin #原来配置
方式1.rpm包源(系统盘文件)1:
[[email protected] ~]# mount -o loop /dev/cdrom /media/ #挂载/dev/cdrom到/media/
#复制系统盘里的安装包到本地/yumserver/centos6.9/Packages
[[email protected] ~]# cp -a /media/Packages/* /yumserver/centos6.9/Packages
#将系统盘里的安装包复制到windows上共享
方式2.rpm包源(系统盘文件,放windows上共享):
[[email protected] ~]# vi /etc/fstab
#自动挂载windows共享到/yumserver/centos6.9/Packages
//192.168.44.1/pack$ /yumserver/centos6.9/Packages cifs defaults,username=Administrator,password=9 0 2
#生产创建仓库
[[email protected] ~]# createrepo -v /yumserver/centos6.9/
#修改httpd配置文件
cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak
sed -i ‘s#DocumentRoot "/var/www/html"#DocumentRoot "/yumserver"#g‘ /etc/httpd/conf/httpd.conf
sed -i ‘s#<Directory "/var/www/html">#<Directory "/yumserver">#g‘ /etc/httpd/conf/httpd.conf
#将主页重命名(应该是删除动作)
mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.bak
[[email protected] ~]# service httpd restart #重启httpd服务
[[email protected] ~]# netstat -lntup|grep httpd #检查一下服务端口有没有运行
#用浏览器测试访问
http://192.168.44.71/centos6.9/
ftp://192.168.44.71/centos6.9/
#客户端配置(http)
#将/etc/yum.repos.d下的所有文件重命名,复制entOS-Media.repo.bak为yum-http.repo
[[email protected] yum.repos.d]# ls
CentOS-Base.repo.bak CentOS-fasttrack.repo.bak CentOS-Vault.repo.bak
CentOS-Debuginfo.repo.bak CentOS-Media.repo.bak yum-http.repo
#编辑yumpack.repo指向
[[email protected] yum.repos.d]# cat yum-http.repo
[yumserver]
name=yum01
baseurl=http://192.168.44.71/centos6.9/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#客户端配置(ftp)
#将/etc/yum.repos.d下的所有文件重命名,复制entOS-Media.repo.bak为yum-ftp.repo
[[email protected] yum.repos.d]# ls
CentOS-Base.repo.bak CentOS-fasttrack.repo.bak CentOS-Vault.repo.bak
CentOS-Debuginfo.repo.bak CentOS-Media.repo.bak yum-ftp.repo
#编辑yumpack.repo指向
[[email protected] yum.repos.d]# cat yum-http.repo
[yumserver]
name=yum01
baseurl=ftp://192.168.44.71/centos6.9/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#查看客户端的yum库
[[email protected] yum.repos.d]# yum clean all #清除缓存
[[email protected] yum.repos.d]# yum repolist #查看yum源列表
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
repo id repo name status
YUM01 YUM01 6,705
repolist: 6,705
[[email protected] yum.repos.d]# yum list|wc -l #统计yum源软件的数量
6739
原文地址:http://blog.51cto.com/yehaixiao/2094551