AI摘要
本文详细介绍了在CentOS 7上搭建HTTP Yum源的步骤。首先,需进行环境准备,包括永久关闭防火墙和SELinux,挂载系统镜像并复制到`/opt/centos`,然后配置本地Yum源。接着,安装并启动httpd服务,创建软链接将`/opt`目录内容指向`/var/www/html`,并清除httpd默认欢迎页。最后重启httpd服务,即可通过HTTP访问Yum源。
CentOS7 搭建http的yum源
1. 环境准备
- 永久关闭防火墙
[root@yum ~]# systemctl stop firewalld && systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.- 永久关闭selinux
[root@yum ~]# setenforce 0
[root@yum ~]# sed -i 's/enforcing/disabled/g' /etc/selinux/config
[root@yum ~]# cat /etc/selinux/config | grep =
# SELINUX= can take one of these three values:
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
SELINUXTYPE=targeted - 挂载系统镜像源
[root@yum ~]# mount -o loop /dev/cdrom /mnt/
[root@yum ~]# mkdir /opt/centos
[root@yum ~]# cp -rf /mnt/* /opt/centos/
[root@yum ~]# umount /mnt/- 备份原有yum源
[root@yum ~]# mkdir yumbackup
[root@yum ~]# mv /etc/yum.repos.d/* yumbackup/- 配置centos系统镜像源
[root@yum ~]# cat << EOF > /etc/yum.repos.d/yum.repo
> [centos]
> name=centos
> baseurl=file:///opt/centos
> gpgcheck=0
> enable=1
> EOF
[root@yum ~]# cat /etc/yum.repos.d/yum.repo
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enable=1
[root@yum ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: centos
[root@yum ~]# yum repolist
Loaded plugins: fastestmirror
Determining fastest mirrors
centos | 3.6 kB 00:00:00
(1/2): centos/group_gz | 153 kB 00:00:00
(2/2): centos/primary_db | 3.3 MB 00:00:00
repo id repo name status
centos centos 4,070
repolist: 4,070- 安装工具
yum install -y vim net-tools2.配置http源
- 安装http
yum install -y httpd
systemctl restart httpd
systemctl enable httpd- 创建软连接指向源路径
[root@yum html]# ln -s /opt/* /var/www/html/- 删除httpd默认页内容
echo "" > /etc/httpd/conf.d/welcome.conf- 重启httpd服务
systemctl restart httpd
评论 (0)