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

打印 上一主题 下一主题

主题 1036|帖子 1036|积分 3108

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

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

  1. '环境准备,修改hostname,关闭防火墙,disabled selinux'
  2. [root@edenluo ~]# hostnamectl set-hostname --static yum-server
  3. [root@edenluo ~]# systemctl disable firewalld --now
  4. [root@edenluo ~]# sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/sysconfig/selinux
复制代码
二、设置服务器端yum

1、安装yum源工具

  1. [root@edenluo ~]# yum -y install epel-release.noarch     # nginx需要epel源
  2. [root@edenluo ~]# yum -y install nginx    # 安装nginx
  3. [root@edenluo ~]# yum -y yum-utils    # 安装repository管理工具
复制代码
2、设置nginx

  1. [root@edenluo nginx]# cd /etc/nginx/
  2. [root@edenluo nginx]# cp nginx.conf{,.bak}    # 备份!备份!备份!
  3. [root@edenluo nginx]# vim nginx.conf
  4.     server {
  5.    
  6.         listen       80;
  7.         server_name  localhost;
  8.         root         /usr/share/nginx/html;
  9.         # Load configuration files for the default server block.
  10.         include /etc/nginx/default.d/*.conf;
  11.         location / {
  12.    
  13.         }
  14.         # 在server段加入以下三段内容
  15.         autoindex on;              # 表示:自动在index.html的索引打开
  16.         autoindex_exact_size on;   # 表示:如果有文件,则显示文件的大小
  17.         autoindex_localtime on;    # 表示:显示更改时间,以当前系统的时间为准
  18.         error_page 404 /404.html;
  19.             location = /40x.html {
  20.    
  21.         }
  22.         error_page 500 502 503 504 /50x.html;
  23.             location = /50x.html {
  24.    
  25.         }
  26.     }
  27.    
  28. [root@edenluo nginx]# nginx -t     # 检测一下nginx语法是否有错
  29. nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
  30. nginx: configuration file /etc/nginx/nginx.conf test is successful
  31. [root@edenluo nginx]# systemctl enable nginx.service --now
  32. Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
  33. [root@edenluo nginx]# systemctl enable nginx.service --now  # 启动nginx,设为开机自启
  34. [root@edenluo nginx]# curl -I http://localhost    # 访问本地,状态码返回200,服务正常
  35. HTTP/1.1 200 OK
  36. Server: nginx/1.16.1
  37. Date: Sun, 05 Jul 2020 09:48:05 GMT
  38. Content-Type: text/html
  39. Content-Length: 4833
  40. Last-Modified: Fri, 16 May 2014 15:12:48 GMT
  41. Connection: keep-alive
  42. ETag: "53762af0-12e1"
  43. Accept-Ranges: bytes
复制代码
3、设置nginx页面貌录

  1. [root@edenluo nginx]# cd /usr/share/nginx/html/
  2. [root@edenluo html]# mkdir -p CentOS-YUM/Aliyun/{version_8,version_7}/64bit
  3. [root@edenluo html]# tree /usr/share/nginx/html/CentOS-YUM/
  4. /usr/share/nginx/html/CentOS-YUM/
  5. └── Aliyun
  6.     ├── version_8
  7.     │   └── 64bit
  8.     └── version_7
  9.         └── 64bit
  10. 5 directories, 0 files
复制代码
  1. [root@edenluo html]# cd CentOS-YUM/
  2. [root@edenluo CentOS-YUM]# vim index.html
  3. <p style="font-weight:bolder;color:green;font-size:30px;">ALL of the packages in the below:</p>
  4. <br/>
  5. <a href="http://192.168.57.133/CentOS-YUM/Aliyun">version_8</a><br/>
  6. These packagers using for Centos 8<br/>
  7. <a href="http://192.168.57.133/CentOS-YUM/Aliyun">version_7</a><br/>
  8. These packagers using for Centos 7<br/>
  9. <p style="font-weight:bolder;color:red;font-size:18px;">Please replace the file and fill in the f    ollowing content:</p>
  10. <p style="font-weight:bolder;color:blue;font-size:15px;">Way: /etc/yum.repos.d/CentOS-Base.repo</    p>
复制代码
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  3. <html>
  4. <head>
  5.   <title>Web Server</title>
  6.   <style rel="stylesheet" type="text/css">
  7.         html {
  8.      
  9.         background-image:url(img/html-background.png);
  10.         background-color: white;
  11.         font-family: "DejaVu Sans"
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

络腮胡菲菲

论坛元老
这个人很懒什么都没写!
快速回复 返回顶部 返回列表