# (四)YUM Server 架設
## Server設定
創立要掛載光碟的資料夾
```
$ mkdir /var/www/html/shu/centos8.2
```
創立要放置 iso 檔案的資料夾
```
$ mkdir /mnt/shu
```
從虛擬機的瀏覽器下載 iso 檔案到 firefox
<font color="red">記得設定預設下載位置</font>

https://www.centos.org/download/ 有最新版本


設定開機掛載功能
```
$ vim /etc/fstab
```
<font color="red">[注意]檔案名稱要跟下載下來的檔案名稱一樣!!!</font>
```dockerfile=
#執行結果
# /etc/fstab
# Created by anaconda on Sun May 30 11:44:06 2021
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
/mnt/shu/CentOS-Stream-8-x86_64-20210721-dvd1.iso /var/www/html/shu/centos8.2
iso9660 defaults,loop,ro 0 0
/dev/mapper/cs-root / xfs defaults 0 0
UUID=5bce6840-f733-4645-b391-16120867f50e /boot xfs defaults 0 0
/dev/mapper/cs-swap none swap defaults 0 0
```
:::info
接著輸入以下幾行(如果沒有下載httpd的話)
:::
```
$ yum -y install httpd
```
```
$ chkconfig httpd on
```
```
$ systemctl start httpd
```
```
$ systemctl enable httpd
```
```
$ firewall-cmd --permanent --zone=public --add-port=80/tcp
```
```
$ firewall-cmd --reload
```
重新開機
```
$ reboot
```
## Client設定
設定yum檔案
```
$ vim /etc/yum.repos.d
```
只留appstream與baseos,其他先註解 如下
```dockerfile=
#執行結果
# CentOS-Stream-Extras.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
# update status of each mirror to pick current mirrors that are geographically
# close to the client. You should use this for CentOS updates unless you are
# manually picking other mirrors.
#
# If the mirrorlist does not work for you, you can try the commented out
# baseurl line instead.
#[extras]
#name=CentOS Stream $releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$stream/extras/$basearch/os/
#gpgcheck=1
#enabled=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
~
```
[appstream]
```dockerfile=
[appstream]
name=CentOS Stream $releasever - AppStream
#mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=AppStream&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$stream/AppStream/$basearch/os/
baseurl=http://chuck.im.shu/shu/centos8.2/AppStream/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
~
```
[baseos]
```dockerfile=
[baseos]
name=CentOS Stream $releasever - BaseOS
#mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=BaseOS&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$stream/BaseOS/$basearch/os/
baseurl=http://chuck.im.shu/shu/centos8.2/BaseOS/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
~
```
## [client測試]
<font color="red">記得網卡要打開</font>
```
$ yum -y install nodejs
```
:::warning
出現Complete! 代表安裝成功
:::