Centos7 hace yum fuente de LAN http

Haga que la fuente yum de la red local sea http

1. Descargue el paquete de instalación localmente, tome la descarga del paquete de software vim como ejemplo

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

2. Copie el paquete de instalación en el servidor yum preestablecido en la LAN

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

3. Instale el servidor httpd

[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. Inicie el servicio httpd y verifique el estado de ejecución.

[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. Cerrar selinux:

1) Apagar e invalidar temporalmente después de reiniciar
[root@localhost yum]# getenforce        //运行命令 getenforce 获取当前selinux状态(Enforcing为开启)
Enforcing
[root@localhost yum]# setenforce 0      //运行命令 setenforce 0
[root@localhost yum]# getenforce       //运行命令getenforce,状态变为 Permissive
Permissive
2) Cerrar permanentemente

Ejecute el comando: 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

Después de reiniciar, ejecute el comando 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

Cerrar selinux de forma permanente con éxito

6. Cree un enlace suave

[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. Visite la página

Inserte la descripción de la imagen aquí

8. Configure el yum del host para que apunte a esta fuente de yum.

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

9. Ver la información de la fuente de yum

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



Supongo que te gusta

Origin blog.csdn.net/m0_52425873/article/details/113075598
Recomendado
Clasificación