1. Experimental environment
server | IP address |
---|---|
Server-side graphical installation | 192.168.153.160 |
Minimal client installation | 192.168.153.180 |
Both the server and the client turn off the firewall and selinux
systemctl stop firewalld
setenforce 0
2. Server configuration
2.1 Create a working directory
mkdir -p /media/CentOS7
2.2 Mount the image file
mount /dev/sr0 /mnt
View mounting results
2.3 Copy files and modify permissions
cp -r /mnt/* /media/CentOS7
chmod -R 777 /media/CentOS7
2.4 Modify the CentOS-Media.repo file
Description
CentOS-Base.repo is the configuration file of yum network source
CentOS-Media.repo is the configuration file of yum local source
Modify CentOS-Media.repo
vim /etc/yum.repos.d/CentOS-Media.repo
The revised content is as follows:
[c7-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS7/
gpgcheck=0
enabled=1
gpgkey=file:///media/CentOS7/RPM-GPG-KEY-CentOS-7
2.5 Disable the default yum network source
vim /etc/yum.repos.d/CentOS-Base.repo
Set the enabled parameter to 0
enabled=0
2.6 Clear yum cache directory
yum clean all
2.7 Establish yum data cache
yum makecache
2.8 View the local yum repo warehouse
[root@host-160 ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
repo id repo name status
c7-media CentOS-7 - Media 9,911
repolist: 9,911
3. The server configures the yum release source based on nginx
3.1 Install nginx from source code
Reference document: https://blog.csdn.net/m0_46674735/article/details/109709606
3.2 Modify nginx configuration file
vim /usr/local/nginx/conf/nginx.conf
The contents of lines 43 to 47 are modified as follows
43 location / {
44 autoindex on;
45 root /media/CentOS7;
46 index index.html index.htm;
47 }
3.3 Open nginx service
/usr/local/nginx/sbin/nginx
3.4 The browser enters the server ip to 192.168.153.160
visit, the result is shown in the figure
4. The client configures the local yum source (http mode)
4.1 Move the repo file that comes with the system to the bak directory
cd /etc/yum.repos.d/
mkdir bak
mv *.repo bak
4.2 Edit local.repo file
vim local.repo
The contents of the local.repo file are as follows
[local]
name=local
baseurl=http://192.168.153.160
gpgcheck=0
enabled=1
4.3 Clear yum cache directory
yum clean all
4.4 Establish yum data cache
yum makecache
4.5 View the native yum repo warehouse
[root@host-180 yum.repos.d]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id repo name status
local local 9,911
repolist: 9,911
4.6 Install httpd test
yum -y install httpd
Successful installation
4.7 Install mysql test
yum -y install mariadb-server
There is an error as shown in the figure,
query the mariadb components installed on this machine
[root@host-180 yum.repos.d]# rpm -qa|grep mariadb
mariadb-libs-5.5.64-1.el7.x86_64
Use the following command to uninstall
rpm -e mariadb-libs-5.5.64-1.el7.x86_64 --nodeps
Install mysql again
yum -y install mariadb-server
Successful installation! ! !
5. Add rpm package to yum source
5.1 Install createrepo
yum install createrepo -y
5.2 Download the specified rpm package to the specified directory (take mariadb-server as an example)
yum install mariadb-server --downloadonly --downloaddir=/media/CentOS7/Packages/
5.3 Update (update every time a rpm package is added)
createrepo --update /media/CentOS7/Packages/
5.4 Re-establish yum cache
Both the server and the client must do the following operations:
yum clean all
yum makecache
Refer to the big guy blog:
https://blog.csdn.net/zhangshaohuas/article/details/109777538