一、需求背景 在某个内网环境中,只有一台服务器可以连接外部网络,在此情况下,需要在该台服务器搭建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 # 修改admin
ServerName 110.18.10.63:6666 # 修改主机
DocumentRoot "/temp/repo/" # 添加代理的yum源目录,此处代理/temp/repo/目录
Directory "/temp/repo/"> # 访问控制
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
Directory>
[root@cheliangweb conf]# cat httpd.conf
ServerRoot "/etc/httpd"
Listen 6666
Include conf.modules.d/*.conf
User apache
Group apache
ServerAdmin root@localhost
Directory />
AllowOverride none
Require all denied
Directory>
DocumentRoot "/temp/"
Directory "/temp/">
AllowOverride None
# Allow open access:
Require all granted
Directory>
Directory "/temp/">
#
#
Options Indexes FollowSymLinks
#
AllowOverride None
#
Require all granted
Directory>
IfModule dir_module>
DirectoryIndex index.html
IfModule>
Files ".ht*">
Require all denied
Files>
ErrorLog "logs/error_log"
LogLevel warn
IfModule 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" combined
IfModule>
IfModule alias_module>
#
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
IfModule>
Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Require all granted
Directory>
IfModule mime_module>
#
TypesConfig /etc/mime.types
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
#
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
IfModule>
AddDefaultCharset UTF-8
IfModule mime_magic_module>
MIMEMagicFile conf/magic
IfModule>
EnableSendfile on
IncludeOptional conf.d/*.conf
[root
[base]
name=CentOS-$releasever - Base - mirror.template.com
baseurl=http://10.18.10.63:6666/repo/base/
path=/
enabled=1
gpgcheck=0
[updates]
name=CentOS-$releasever - Updates - mirror.template.com
baseurl=http://10.18.10.63:6666/repo/updates/
path=/
enabled=1
gpgcheck=0
[extras]
name=CentOS-$releasever - Extras - mirrors.template.com
baseurl=http://10.18.10.63:6666/repo/extras/
path=/
enabled=1
gpgcheck=0
[epel]
name=CentOS-$releasever - epel - mirrors.template.com
baseurl=http://10.18.10.63:6666/repo/epel/
failovermethod=priority
enabled=1
gpgcheck=0
[docker-ce]
name=docker-ce
baseurl=http://10.18.10.63:6666/repo/docker-ce-stable
path=/
enabled=1
gpgcheck=0
[root@wqcycdldp1 yum.repos.d]# yum repolist
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
repo 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,766
repolist: 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 16 次阅读