观察一下使用的各大开源软件镜像站的yum源,思考他们是怎么创建的呢?我们自己能否创建呢?当然能。

1、安装web服务,本例选择nginx。配置过程不多说,本例选择的根目录是/var/repos,添加三个选项可以看到包的大小和修改日期。

[[email protected] ~]# yum install nginx
[[email protected] ~]# cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/repo.conf
[[email protected] ~]# vim /etc/nginx/conf.d/repo.conf
server {
    listen       80;
    server_name  localhost;

    location / {
        root   /var/repos;
        autoindex on;                        #开启目录浏览功能;
        autoindex_exact_size off;            #关闭详细文件大小统计,让文件大小显示MB,GB单位,默认为b;
        autoindex_localtime on;              #开启以服务器本地时区显示文件修改日期!
    }
}

[[email protected] ~]# systemctl enable nginx
[[email protected] ~]# systemctl start nginx

2、把rpm包放到web服务器的根目录下一个指定目录,本例使用的目录是centos/8/Packages,把编译好的openssh-8.5p1-el8的包放到该目录

[[email protected] ~]# cd /var/repos/
[[email protected] repos]# mkdir -p centos/8/Packages/
[[email protected] repos]# cp ~rpmbuilder/rpmbuild/RPMS/x86_64/openssh-* centos/8/Packages/

3、安装创建yum源的工具createrepo


[[email protected] repos]# yum provides createrepo
Last metadata expiration check: 0:07:47 ago on Mon 15 Mar 2021 10:45:57 PM CST.
createrepo_c-0.15.11-2.el8.x86_64 : Creates a common metadata repository
Repo        : @System
Matched from:
Provide    : createrepo = 0.15.11-2.el8

[[email protected] repos]# yum install createrepo_c

4、创建repodata

[[email protected] repos]# cd centos/8/
[[email protected] 8]# createrepo -o . Packages/
[[email protected] 8]# ll
total 8
drwxr-xr-x. 2 root root 4096 Mar 15 22:30 Packages
drwxr-xr-x. 2 root root 4096 Mar 15 22:32 repodata

5、配置yum方式和其他yum配置方式,正常使用即可

[[email protected] yum.repos.d]# vim self.repo
[self]
name=self
baseurl=http://192.168.37.149/centos/8/
enabed=1
gpgcheck=0

[[email protected] yum.repos.d]# yum clean all
41 files removed
[[email protected] yum.repos.d]# yum makecache
self                                                                                                                1.9 MB/s | 5.8 kB     00:00
Metadata cache created.

[[email protected] yum.repos.d]# yum list available
Last metadata expiration check: 0:01:01 ago on Mon 15 Mar 2021 10:57:05PM CST.
Available Packages
openssh.x86_64                              8.5p1-1.el8             self
openssh-clients.x86_64                      8.5p1-1.el8             self
openssh-clients-debuginfo.x86_64            8.5p1-1.el8             self
openssh-debuginfo.x86_64                    8.5p1-1.el8             self
openssh-debugsource.x86_64                  8.5p1-1.el8             self
openssh-server.x86_64                       8.5p1-1.el8             self
openssh-server-debuginfo.x86_64             8.5p1-1.el8             sel

标签: root, yum, 创建, repos, self, createrepo, el8

相关文章推荐

添加新评论,含*的栏目为必填