> For the complete documentation index, see [llms.txt](https://pshizhsysu.gitbook.io/linux/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pshizhsysu.gitbook.io/linux/yum/ben-di-yum-yuan.md).

# 本地yum源

本文将介绍如何制作与使用本地yum源。假设我们本地yum源的路径规划为`/var/yum/centos`。

1、创建目录`/var/yum/centos/Packages`

```
$ mkdir -p /var/yum/centos/Packages
```

2、拷贝rpm包

把rpm包拷贝到`/var/yum/centos/Packages`目录下

3、生成`repodata`目录

```
$ createrepo -d /var/yum/centos
```

执行该命令后，便会在`/var/yum/centos/`下生成一个`repodata`目录，里面包含了元数据

4、在该主机上使用这个yum源

在该主机上，新建文件`/etc/yum.repos.d/localhost.repo`，内容如下

```
[localhost]
name=localhost
baseurl=file:///var/yum/centos/
enabled=1
gpgcheck=0
```
