ローカルネットワークのyumソースをhttpにします
1.インストールパッケージをローカルにダウンロードします。例としてvimソフトウェアパッケージをダウンロードします。
yum install --downloadonly --downloaddir=/opt/download vim
2.インストールパッケージをLAN上の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