CentOS7 builds a local yum warehouse based on http service

Since the company's intranet server cannot access the external network, it is relatively troublesome to install software, so you can choose a host to build a local yum warehouse. This article chooses to use http service to build.
Experimental environment: CentOS 7
warehouse host: 192.168.20.181
Test host: 192.168.20.182
firewall and selinux turned off
1. Build YUM local source based on ISO image
First load the CD/DVD drive iso image to the virtual machine CD/DVD, create and hang the directory mkdir -p /mnt/cdrom
Insert picture description here
2. Create a repo file
[root@localhost ~]# mv /etc/yum.repos.d/* /tmp/ #It’s just for experimentation, it doesn’t actually need to be removed

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# cat centos-local.repo 
[loca-repo]
name=local-repo
baseurl=file:///mnt/cdrom
enabled=1
gpgcheck=0

Note: The repo file must end with ".repo"
3. Install httpd and start

[root@localhost ~]# yum -y install httpd
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# netstat -nlpt | grep 80  #查看80端口是否开启
tcp6       0      0 :::80                   :::*                    LISTEN      23757/httpd         
[root@localhost ~]# ln -s /mnt/cdrom/ /var/www/html/centos  #创建软连接指向挂载的镜像

4. Test the host configuration

[root@localhost ~]# mv /etc/yum.repos.d/* /tmp/  #只是为了试验效果,实际可不必移除
[root@localhost ~]# cat /etc/yum.repos.d/centos-local-http.repo
[http-repos]
name=http-repos 
baseurl=http://192.168.20.181/centos
gpgcheck=0
enabled=1 

[root@localhost ~]# yum repolist
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
http-repos                                                              | 3.6 kB  00:00:00     
(1/2): http-repos/group_gz                                              | 166 kB  00:00:00     
(2/2): http-repos/primary_db                                            | 5.9 MB  00:00:00     
源标识                                       源名称                                       状态
http-repos                                   http-repos                                   9,911
repolist: 9,911

Guess you like

Origin blog.csdn.net/lq_hello/article/details/107234726
Recommended