络腮胡菲菲 发表于 2024-10-27 19:54:10

全网CentOS7下的YUM源服务器最全搭建步骤

今天给伙伴们分享一下CentOS7下的YUM源服务器最全搭建步骤,希望看了有所劳绩。
   我是公众号「想吃西红柿」「云原生运维实战派」作者,对云原生运维感爱好,也保持时刻学习,后续会分享工作中用到的运维技术,在运维的路上得到支持和共同进步!
如果伙伴们看了文档觉得有用,接待大家关注我的公众号,获取相关文档。爱运维,爱生存。
一、环境要求

'环境准备,修改hostname,关闭防火墙,disabled selinux'
# hostnamectl set-hostname --static yum-server
# systemctl disable firewalld --now
# sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/sysconfig/selinux
二、设置服务器端yum

1、安装yum源工具

# yum -y install epel-release.noarch   # nginx需要epel源
# yum -y install nginx    # 安装nginx
# yum -y yum-utils    # 安装repository管理工具
2、设置nginx

# cd /etc/nginx/
# cp nginx.conf{,.bak}    # 备份!备份!备份!
# vim nginx.conf
    server {
   
      listen       80;
      server_namelocalhost;
      root         /usr/share/nginx/html;

      # Load configuration files for the default server block.
      include /etc/nginx/default.d/*.conf;

      location / {
   
      }
      # 在server段加入以下三段内容
      autoindex on;            # 表示:自动在index.html的索引打开
      autoindex_exact_size on;   # 表示:如果有文件,则显示文件的大小
      autoindex_localtime on;    # 表示:显示更改时间,以当前系统的时间为准

      error_page 404 /404.html;
            location = /40x.html {
   
      }

      error_page 500 502 503 504 /50x.html;
            location = /50x.html {
   
      }
    }
   
# nginx -t   # 检测一下nginx语法是否有错
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

# systemctl enable nginx.service --now
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

# systemctl enable nginx.service --now# 启动nginx,设为开机自启
# curl -I http://localhost    # 访问本地,状态码返回200,服务正常
HTTP/1.1 200 OK
Server: nginx/1.16.1
Date: Sun, 05 Jul 2020 09:48:05 GMT
Content-Type: text/html
Content-Length: 4833
Last-Modified: Fri, 16 May 2014 15:12:48 GMT
Connection: keep-alive
ETag: "53762af0-12e1"
Accept-Ranges: bytes
3、设置nginx页面貌录

# cd /usr/share/nginx/html/
# mkdir -p CentOS-YUM/Aliyun/{version_8,version_7}/64bit
# tree /usr/share/nginx/html/CentOS-YUM/
/usr/share/nginx/html/CentOS-YUM/
└── Aliyun
    ├── version_8
    │   └── 64bit
    └── version_7
      └── 64bit

5 directories, 0 files
# cd CentOS-YUM/
# vim index.html
<p style="font-weight:bolder;color:green;font-size:30px;">ALL of the packages in the below:</p>
<br/>

<a href="http://192.168.57.133/CentOS-YUM/Aliyun">version_8</a><br/>

These packagers using for Centos 8<br/>

<a href="http://192.168.57.133/CentOS-YUM/Aliyun">version_7</a><br/>

These packagers using for Centos 7<br/>

<p style="font-weight:bolder;color:red;font-size:18px;">Please replace the file and fill in the f    ollowing content:</p>
<p style="font-weight:bolder;color:blue;font-size:15px;">Way: /etc/yum.repos.d/CentOS-Base.repo</    p>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<html>
<head>
<title>Web Server</title>
<style rel="stylesheet" type="text/css">

      html {
   
      background-image:url(img/html-background.png);
      background-color: white;
      font-family: "DejaVu Sans"
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: 全网CentOS7下的YUM源服务器最全搭建步骤