一、需求背景 在某个内网环境中,只有一台服务器可以连接外部网络,在此情况下,需要在该台服务器搭建yum源,以便其他内网服务器能够使用yum安装软件以解决依赖关系。 目前已经完成将yum仓库同步到本地,现在需要进行后续配置。二、在服务端配置httpdyum -y install httpdvim /etc/httpd/conf/httpd.conf ##修改以下内容即可主要修改以下几行内容: 下附配置文件完整内容: #配置完毕后启动httpd systemctl start httpd systemctl restart httpd systemctl status httpd三、在客户端配置reporepo文件的内容如下: 四、测试验证访问浏览器页面如下: yum clean all yum makecache yum list yum repolistServerAdmin root@10.18.10.63 # 修改adminServerName 110.18.10.63:6666 # 修改主机DocumentRoot "/temp/repo/" # 添加代理的yum源目录,此处代理/temp/repo/目录Directory "/temp/repo/"> # 访问控制 Options Indexes FollowSymLinks AllowOverride None Require all grantedDirectory>[root@cheliangweb conf]# cat httpd.confServerRoot "/etc/httpd"Listen 6666Include conf.modules.d/*.confUser apacheGroup apacheServerAdmin root@localhostDirectory /> AllowOverride none Require all deniedDirectory>DocumentRoot "/temp/"Directory "/temp/"> AllowOverride None # Allow open access: Require all grantedDirectory>Directory "/temp/"> # # Options Indexes FollowSymLinks # AllowOverride None # Require all grantedDirectory>IfModule dir_module> DirectoryIndex index.htmlIfModule>Files ".ht*"> Require all deniedFiles>ErrorLog "logs/error_log"LogLevel warnIfModule log_config_module> # LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined LogFormat "%h %l %u %t "%r" %>s %b" common IfModule logio_module> LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i" %I %O" combinedio IfModule> # CustomLog "logs/access_log" combinedIfModule>IfModule alias_module> # ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"IfModule>Directory "/var/www/cgi-bin"> AllowOverride None Options None Require all grantedDirectory>IfModule mime_module> # TypesConfig /etc/mime.types # AddType application/x-compress .Z AddType application/x-gzip .gz .tgz # AddType text/html .shtml AddOutputFilter INCLUDES .shtmlIfModule>AddDefaultCharset UTF-8IfModule mime_magic_module> MIMEMagicFile conf/magicIfModule>EnableSendfile onIncludeOptional conf.d/*.conf[root[base]name=CentOS-$releasever - Base - mirror.template.combaseurl=http://10.18.10.63:6666/repo/base/path=/enabled=1gpgcheck=0[updates]name=CentOS-$releasever - Updates - mirror.template.combaseurl=http://10.18.10.63:6666/repo/updates/path=/enabled=1gpgcheck=0[extras]name=CentOS-$releasever - Extras - mirrors.template.combaseurl=http://10.18.10.63:6666/repo/extras/path=/enabled=1gpgcheck=0[epel]name=CentOS-$releasever - epel - mirrors.template.combaseurl=http://10.18.10.63:6666/repo/epel/failovermethod=priorityenabled=1gpgcheck=0[docker-ce] name=docker-cebaseurl=http://10.18.10.63:6666/repo/docker-ce-stablepath=/ enabled=1gpgcheck=0 

[root@wqcycdldp1 yum.repos.d]# yum repolistLoaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-managerThis system is not registered with an entitlement server. You can use subscription-manager to register.Loading mirror speeds from cached hostfilerepo id repo name status!base CentOS-7 - Base - mirror.template.com 10,072!docker-ce docker-ce 337!epel CentOS-7 - epel - mirrors.template.com 13,790!extras CentOS-7 - Extras - mirrors.template.com 278!updates CentOS-7 - Updates - mirror.template.com 1,766repolist: 26,243
参考资料链接:https://blog.csdn.net/weixin_44296364/article/details/123136110https://www.cnblogs.com/reachos/p/11303843.html
在CentOS 7下使用阿里云yum源搭建本地yum仓库(2):配置httpd服务构建yum仓库供客户端访问【测试成功】
发布于 2025-04-02 48 次阅读
