Centos7 makes yum source of LAN http

Make the yum source of the local network http

1. Download the installation package to the local, take downloading the vim software package as an example

yum install --downloadonly --downloaddir=/opt/download vim 

2. Copy the installation package to the yum server preset on the LAN

[root@localhost yum]# cd /opt/yum	     进入到软件包所在文件夹
[root@localhost yum]# createrepo .     创建每个软件包元数据
[root@localhost yum]# createrepo update  软件仓库中含有很多的软件包,虽然只是其中的一小部分有所改动但是你却不必为每个软件包重新产生元数据,这样做明显太浪费时间了

3. Install httpd server

[root@localhost yum]# yum -y install httpd
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 httpd.x86_64.0.2.4.6-97.el7.centos 将被 安装
--> 正在处理依赖关系 httpd-tools = 2.4.6-97.el7.centos,它被软件包 httpd-2.4.6-97.el7.centos.x86_64 需要
--> 正在处理依赖关系 /etc/mime.types,它被软件包 httpd-2.4.6-97.el7.centos.x86_64 需要
--> 正在处理依赖关系 libaprutil-1.so.0()(64bit),它被软件包 httpd-2.4.6-97.el7.centos.x86_64 需要
--> 正在处理依赖关系 libapr-1.so.0()(64bit),它被软件包 httpd-2.4.6-97.el7.centos.x86_64 需要

4. Start the httpd service and check the running status

[root@localhost /]# systemctl enable httpd  //开机自启动
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@localhost /]# systemctl start httpd  //开启服务
[root@localhost /]# systemctl status httpd  //查看服务状态
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since 六 2021-01-23 19:11:22 PST; 6s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 23938 (httpd)
   Status: "Processing requests..."
   CGroup: /system.slice/httpd.service
           ├─23938 /usr/sbin/httpd -DFOREGROUND
           ├─23941 /usr/sbin/httpd -DFOREGROUND
           ├─23942 /usr/sbin/httpd -DFOREGROUND
           ├─23943 /usr/sbin/httpd -DFOREGROUND
           ├─23944 /usr/sbin/httpd -DFOREGROUND
           └─23945 /usr/sbin/httpd -DFOREGROUND

1月 23 19:11:22 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
1月 23 19:11:22 localhost.localdomain httpd[23938]: AH00558: httpd: Could not reliably determine the server's fully qu...ssage
1月 23 19:11:22 localhost.localdomain systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.

5. Close selinux:

1) Temporarily shut down and invalidate after restart
[root@localhost yum]# getenforce        //运行命令 getenforce 获取当前selinux状态(Enforcing为开启)
Enforcing
[root@localhost yum]# setenforce 0      //运行命令 setenforce 0
[root@localhost yum]# getenforce       //运行命令getenforce,状态变为 Permissive
Permissive
2) Close permanently

Run the command: vim /etc/sysconfig/selinux


# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled    #找到行:SELINUX=enforcing  替换为:SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

After restarting, run the command sestatus

[root@localhost yum]# sestatus
SELinux status:                 `disabled`
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   permissive
Mode from config file:          disabled
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      28

Successfully close selinux permanently

6. Create a soft link

[root@localhost /]# ln -s /opt/yum/ /var/www/html/centos
[root@localhost /]# ll /var/www/html/
总用量 0
lrwxrwxrwx. 1 root root 9 1月  23 19:13 centos -> /opt/yum/

7. Visit the page

Insert picture description here

8. Configure the host's yum to point to this yum source

[root@localhost /]# vim /etc/yum.repos.d/centos.repo
[centos]
name=centos
baseurl=http://192.168.1.119/centos
gpgcheck=0
enabled=1

9. View yum source information

[root@localhost /]# yum repolist 
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
源标识                                                       源名称                                                       状态
centos                                                       centos                                                       3,894
repolist: 3,894



Guess you like

Origin blog.csdn.net/m0_52425873/article/details/113075598