CentOS7 搭建http的yum源

1585364631
2023-03-20 / 0 评论 / 238 阅读 / 正在检测是否收录...

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-tools

2.配置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

评论 (0)

取消