linux
  • Introduction
  • Yum
    • 基础yum源的配置
    • 为yum源配置代理
    • Centos指定版本的yum源
    • 环境变量
    • 本地yum源
    • 制作yum源
      • 同步yum源
    • epel源
  • Iptables
    • 基本匹配条件
    • Match-Extensions
      • Addrtype
      • Set
      • TCP
    • Target-Extensions
      • DNAT
      • LOG
    • Iptables规则持久化
    • 连接追踪
  • LVS
    • Ipvsadm命令
  • 磁盘与分区
    • 创建分区
    • 格式化与挂载
    • fstab
    • LVM
      • LVM扩容
    • swap分区
    • tmpfs
  • 网络相关
    • 重命名网卡
    • resolv.conf
    • Tcpdump
    • dig与nslookup
  • Other
    • CPU与内存
    • 进程
      • 僵尸进程
    • SSH密钥登录
    • 用户管理
    • Crontab
  • Nofile
    • 原理
  • 常用软件安装篇
    • MYSQL
    • 系统与内核
      • 指定内核启动
    • NFS
    • Haproxy
    • Keepalived
    • Squid
    • Redsocks
    • Shadowsocks
    • 时钟同步
  • 内存
Powered by GitBook
On this page
  • 目标
  • 步骤
  • 一、安装httpd
  • 二、安装createrepo
  • 三、使用yum源(M2上)
  • 常见问题
  • 参考文档

Was this helpful?

  1. Yum

制作yum源

目标

  • 主机M1:安装 httpd + createrepo

  • 主机M2:使用M1的yum源

步骤

一、安装httpd

1、安装httpd

$ yum -y install httpd

2、配置httpd

2.1 修改httpd的数据根目录与绑定端口(可选)

httpd的数据根目录默认为/var/www/html/,默认监听127.0.0.1:80。如果需要修改,在配置文件 /etc/httpd/conf/httpd.conf 中修改如下两行

DocumentRoot "/home/pshizh/apps/httpd/DocumentRoot"
Listen 132.122.239.2:8050

备注:如果目录/home/pshizh/apps/httpd/DocumentRoot不存在,则须创建,否则会启动失败

2.2 为数据根目录添加访问权限规则

(如果使用默认路径/var/www/html/,则此步可省略,如果使用新的目录作为数据根目录,则添加如下内容) 在配置文件 /etc/httpd/conf/httpd.conf 中添加如下内容

<Directory "/home/pshizh/apps/httpd/DocumentRoot">
    Options Indexes FollowSymlinks
    AllowOverride None
    Require all granted
</Directory>

3、启动并验证

$ setenforce 0 
$ systemctl start httpd

此时,可以访问 132.122.239.2:8050验证启动是否成功

二、安装createrepo

4、安装createrepo

$ yum -y install createrepo

5、创建yum源的根目录

创建文件夹 /home/pshizh/apps/httpd/DocumentRoot/centos作为yum源的根目录

6、在centos目录下创建目录packages,并把rpm包拷贝到packages目录下

7、创建yum源

$ createrepo -d /home/pshizh/apps/httpd/DocumentRoot/centos

该步骤完成后,在centos目录下会出现一个repodata目录,里面保存了yum源的数据

8、访问132.122.239.2:8050/centos

8.1、更新yum源

如果packages中新增了rpm包,执行下列命令更新yum源

$ createrepo --update /home/pshizh/apps/httpd/DocumentRoot/centos

三、使用yum源(M2上)

9、在/etc/yum.repo.d/下创建 qiiaojing.repo文件,内容如下

[qiaojing]
name=qiaojing
baseurl=http://132.122.239.2:8050/centos
enabled=1
gpgcheck=0

10、更新cache

$ yum clean all & yum makecache

11、查看M1中可安装的软件

$ yum list | grep qiaojing

常见问题

1、Permission denied: AH00072: make_sock: could not bind to address

解决方法:setenforce 0

2、访问 132.122.239.2:8050/centos 时出现 403 forbidden

解决方法:按照2.2配置数据根目录的权限

参考文档

Previous本地yum源Next同步yum源

Last updated 5 years ago

Was this helpful?

https://my.oschina.net/u/1461927/blog/372147
http://linux.51yip.com/search/createrepo