日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

centos7 yum源_搭建内网Linux CentOS yum源,摆脱依赖包困扰

發布時間:2025/10/17 76 豆豆
生活随笔 收集整理的這篇文章主要介紹了 centos7 yum源_搭建内网Linux CentOS yum源,摆脱依赖包困扰 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

什么是yum源?

yum源就是使用yum命令下載軟件的鏡像地址。

我們通常使用 yum install 命令來在線安裝 linux系統的軟件, 這種方式可以自動處理依賴性關系,并且一次安裝所有依賴的軟體包,但是經常會遇到從國外鏡像下載速度慢,無法下載的情況。或者內網無法訪問公網的情況,那么此時我們就需要一個穩定的yum 源作為我們日常使用的地址。

首先,選擇一個穩定的公網yum源,這里我們選擇阿里的yum源,地址:https://developer.aliyun.com/mirror

第一步:安裝Nginx

1、關閉防火墻和SElinux

2、nginx安裝:

依賴包:

yum -y install gcc* zlib-devel pcre pcre-devel openssl-devel perl perl-devel perl-ExtUtils-Embed

參數:

./configure --prefix=/opt/1s1k/nginx-1.12.1 --with-http_stub_status_module --without-poll_module --without-select_module --with-http_ssl_module --with-http_realip_module --with-http_perl_module --with-pcre-jit --error-log-path=/opt/1s1k/nginx-1.12.1/logs/error.log --http-log-path=/opt/1s1k/nginx-1.12.1/logs/access.log

第二步、配置nginx服務

1、修改nginx配置文件/usr/local/nginx/conf/nginx.conf

增加:

autoindex on; 表示自動在index.html的索引打開

autoindex_exact_size on; 表示如果有文件則顯示文件大小

autoindex_localtime on; 表示顯示更改時間,以當前系統時間為準

2、配置完成后運行nginx服務

啟動:/usr/local/nginx/sbin/nginx

重啟:/usr/local/nginx/sbin/nginx -s reload

關閉:/usr/local/nginx/sbin/nginx -s stop

3、創建index.html文件

/usr/local/nginx/html/index.html

在index.html中加入下面內容,CentOS7-Ali目錄是后面放置rpm包的目錄。

ALL of the packages in the below:

Aliyun

These packagers from of CentO`S ISO.

CentOS

These packagers from of "Internet service provider".

Please replace the file and fill in the following content:

Way: /etc/yum.repos.d/CentOS-Base.repo

4、在/usr/local/nginx/html中創建CentOS7-Ali目錄

增加目錄的執行權限

Chmod –R +x /usr/local/nginx/html/

第三步、同步公網YUM源

1、同步并下載阿里源中CentOS7的包,第一次同步下載時間會比較長

reposync -p /usr/local/nginx/html/CentOS7-Ali

同步完成后在web界面會看到新建的三個目錄

2、創建yum源倉庫

使用createrepo -p .命令創建repodata文件。

第四步、配置客戶端的yum源

yum-config-manager --add-repo="http://10.100.50.120/CentOS7-Ali/base/Packages"

配置完成后使用 yum makecache命令更新緩存成功。

第五步、通過定時任務方式讓yum源自動到阿里源更新。

1、創建更新腳本:/usr/local/nginx/sbin/yumupdate.sh

“-np”的意思為僅僅更新新更新的軟件到指定目錄

2、配置定時任務。

run-parts的意思是執行后面目錄中的腳本

總結

以上是生活随笔為你收集整理的centos7 yum源_搭建内网Linux CentOS yum源,摆脱依赖包困扰的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。