马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
x
今天给伙伴们分享一下CentOS7下的YUM源服务器最全搭建步骤,希望看了有所劳绩。
我是公众号「想吃西红柿」「云原生运维实战派」作者,对云原生运维感爱好,也保持时刻学习,后续会分享工作中用到的运维技术,在运维的路上得到支持和共同进步!
如果伙伴们看了文档觉得有用,接待大家关注我的公众号,获取相关文档。爱运维,爱生存。
一、环境要求
- '环境准备,修改hostname,关闭防火墙,disabled selinux'
- [root@edenluo ~]# hostnamectl set-hostname --static yum-server
- [root@edenluo ~]# systemctl disable firewalld --now
- [root@edenluo ~]# sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/sysconfig/selinux
复制代码 二、设置服务器端yum
1、安装yum源工具
- [root@edenluo ~]# yum -y install epel-release.noarch # nginx需要epel源
- [root@edenluo ~]# yum -y install nginx # 安装nginx
- [root@edenluo ~]# yum -y yum-utils # 安装repository管理工具
复制代码 2、设置nginx
- [root@edenluo nginx]# cd /etc/nginx/
- [root@edenluo nginx]# cp nginx.conf{,.bak} # 备份!备份!备份!
- [root@edenluo nginx]# vim nginx.conf
- server {
-
- listen 80;
- server_name localhost;
- 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 {
-
- }
- }
-
- [root@edenluo nginx]# nginx -t # 检测一下nginx语法是否有错
- nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
- nginx: configuration file /etc/nginx/nginx.conf test is successful
- [root@edenluo nginx]# systemctl enable nginx.service --now
- Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
- [root@edenluo nginx]# systemctl enable nginx.service --now # 启动nginx,设为开机自启
- [root@edenluo 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页面貌录
- [root@edenluo nginx]# cd /usr/share/nginx/html/
- [root@edenluo html]# mkdir -p CentOS-YUM/Aliyun/{version_8,version_7}/64bit
- [root@edenluo html]# tree /usr/share/nginx/html/CentOS-YUM/
- /usr/share/nginx/html/CentOS-YUM/
- └── Aliyun
- ├── version_8
- │ └── 64bit
- └── version_7
- └── 64bit
- 5 directories, 0 files
复制代码- [root@edenluo html]# cd CentOS-YUM/
- [root@edenluo 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企服之家,中国第一个企服评测及商务社交产业平台。 |