首先查看系統版本號,而後根據版本號從 CentOS-7-x86_64-DVD-1708.iso 和 CentOS-7-x86_64-Everything-1708.iso 根據須要選擇一個下載,我這裏是7.4.1708nginx
# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core) centos# wget http://vault.centos.org/7.4.1708/isos/x86_64/CentOS-7-x86_64-DVD-1708.iso
# mkdir /mnt/centos7
# mount -o loop,ro CentOS-7-x86_64-DVD-1708.iso /mnt/centos7oop
將以前的repo備份測試
# mkdir /etc/yum.repo.d/bak
# mv /etc/yum.repo.d/*.repo /etc/yum.repo.d/bak/url
如下任選其一centos7
# vi /etc/yum.repos.d/centos7_iso.repo
[centos7-Server]
name=ServerFault Answer
baseurl=file:///mnt/centos7
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
enabled=1
gpgcheck=1get
# cp -a /mnt/centos7/ /yum/io
# vi /etc/yum.repos.d/centos7_localhost.repo
[centos7-Server]
name=ServerFault Answer
baseurl=file:///yum/centos7
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
enabled=1
gpgcheck=1ftp
# vi /etc/yum.repos.d/centos7_localnetwork.repo
[centos7-Server]
name=ServerFault Answer
baseurl=http://192.168.0.1/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
enabled=1
gpgcheck=1配置
其中nginx配置以下(增長一個location)
location / {
root /yum/centos7;
autoindex on;
}
測試
# yum repolist# yum install $anything