Centos7制作局域网http的yum源

制作局域网http的yum源

1、下载安装包到本地,以下载vim软件包为例

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

2、将安装包拷贝至局域网预先设置好的yum服务器

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

3、安装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、启动httpd服务,并查看运行状态

[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、关闭selinux:

1)暂时关闭,重启后失效
[root@localhost yum]# getenforce        //运行命令 getenforce 获取当前selinux状态(Enforcing为开启)
Enforcing
[root@localhost yum]# setenforce 0      //运行命令 setenforce 0
[root@localhost yum]# getenforce       //运行命令getenforce,状态变为 Permissive
Permissive
2)永久关闭

运行命令: 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

重启后,运行命令 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

永久关闭selinux成功

6、创建软链接

[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、访问该页面

在这里插入图片描述

8、配置主机的yum指向这个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、查看yum源信息

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



猜你喜欢

转载自blog.csdn.net/m0_52425873/article/details/113075598