搭建本地yum源的所有步骤如下:#准备好一个centos 的镜像,我这里是CentOS-7-x86_64-DVD-1810.iso# 在/local-yum目录创建挂载镜像的文件夹# 将iso镜像挂载到/mnt/iso目录mount -o loop CentOS-7-x86_64-DVD-1810.iso /local-yum# 挂载成功后可以使用df -h命令查看[root@localhost application]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/centos-root 50G 1.9G 49G 4% /devtmpfs 63G 0 63G 0% /devtmpfs 63G 0 63G 0% /dev/shmtmpfs 63G 11M 63G 1% /runtmpfs 63G 0 63G 0% /sys/fs/cgroup/dev/sda2 1014M 138M 877M 14% /boot/dev/sda1 200M 12M 189M 6% /boot/efi/dev/mapper/centos-home 392G 9.0G 383G 3% /hometmpfs 13G 0 13G 0% /run/user/0/dev/loop0 4.5G 4.5G 0 100% /local-yum# 修改yum配置文件,把原先的配置先备份了cd /etc/yum.repos.dmkdir bakmv *.repo ./bak#新建local.repovim /etc/yum.repos.d/local.repo[base]name=CentOSbaseurl=file:///local-yumenabled=1gpgcheck=0#清除下yum 原有的信息,载入新的缓存yum clean allyum makecache这样,一个崭新的本地yum源就可以使用了。
搭建局域网yum源除了可以搭建本地yum源外,我们还可以基于HTTP方式配置yum源,这样我们就可以配置一个局域网内都可以使用的yum源。
一般都是通过apache 来搭建HTTP的yum源,本次我们使用Nginx搭建#官网下载nginx1.18.0wget http://nginx.org/download/nginx-1.18.0.tar.gz#安装依赖包,NGINX是C语言写的,pcre-devel支持正则表达式,openssl 开启加密[root@proxy ~]# yum -y install gcc pcre-devel openssl-devel #创建NGINX用户,为了安全起见,不允许登录系统[root@proxy ~]# useradd -s /sbin/nologin nginx #解压,安装,这里把nginx 部署在/home/application/nginx 目录下[root@proxy ~]# mkdir /home/application/nginx [root@proxy ~]# tar -xf nginx-1.18.0.tar.gz[root@proxy ~]# cd nginx-1.18.0[root@proxy nginx-1.18.0]# ./configure --prefix=/home/application/nginx --user=nginx --group=nginx --with-http_ssl_module#编译安装[root@proxy nginx-1.10.3]# make && make install#创建yum仓库文件路径 /home/application/nginx-yum[root@proxy ~]#mkdir -p /home/application/nginx-yum #编辑nginx 配置文件,定义端口为8899[root@proxy ~]# vim /home/application/nginx/conf/nginx.confworker_processes 1;events { worker_connections 1024;}http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 8899; server_name localhost; location / { autoindex on; root /home/application/nginx-yum/; } }}#检查nginx 配置文件是否正确[root@proxy ~]# /home/application/nginx/sbin/nginx -tnginx: the configuration file /home/application/nginx/conf/nginx.conf syntax is oknginx: configuration file /home/application/nginx/conf/nginx.conf test is successful#将iso镜像文件挂载到临时目录下,再拷贝到yum仓库路径下 /home/application/nginx-yum[root@proxy ~]# mkdir local-yum[root@proxy ~]# mount -o loop CentOS-7-x86_64-DVD-1810.iso /local-yum[root@proxy ~]# cd local-yum[root@proxy ~]# cp -rp * /home/application/nginx-yum/[root@proxy ~]# ls -l /home/application/nginx-yum/total 4669768-rw-r--r--. 1 root root 4781506560 Aug 17 18:36 CentOS-7-x86_64-DVD-2003.iso-rw-rw-r--. 1 root root 14 Apr 21 2020 CentOS_BuildTagdrwxr-xr-x. 3 root root 35 Apr 21 2020 EFI-rw-rw-r--. 1 root root 227 Aug 30 2017 EULA-rw-rw-r--. 1 root root 18009 Dec 10 2015 GPLdrwxr-xr-x. 3 root root 57 Apr 21 2020 imagesdrwxr-xr-x. 2 root root 198 Apr 21 2020 isolinuxdrwxr-xr-x. 2 root root 43 Apr 21 2020 LiveOSdrwxr-xr-x. 2 root root 225280 Apr 22 2020 Packagesdrwxrwxr-x. 2 root root 4096 Apr 22 2020 repodata-rw-rw-r--. 1 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-7-rw-rw-r--. 1 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-Testing-7-r--r--r--. 1 root root 2883 Apr 22 2020 TRANS.TBL#确认配置没有问题后,启动nginx[root@proxy ~]# /home/application/nginx/sbin/nginx#查看端口[root@localhost conf]# netstat -ntlup Active Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 16129/sshd tcp 0 0 0.0.0.0:8899 0.0.0.0:* LISTEN 41103/nginx: master tcp6 0 0 :::22 :::* LISTEN
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)