共计 2058 个字符,预计需要花费 6 分钟才能阅读完成。
RedHat Linux 7 搭建 yum 源服务器
1. 新建目录
# mkdir -p /content/rhel7.1/x86_64/{isos,dvd}/
2. 上传 RedHat 安装光盘镜像,上传后的路径为 /content/rhel7.1/x86_64/isos/rhel-server-7.1-x86_64-dvd.iso
3. 设置开机自动挂载光盘镜像到 /content/rhel7.1/x86_64/dvd
# echo “/content/rhel7.1/x86_64/isos/rhel-server-7.1-x86_64-dvd.iso /content/rhel7.1/x86_64/dvd iso9660 loop,ro 0 0” >> /etc/fstab
# mount -a
4. 搭建 http 服务器(nginx),用来网络访问这个 yum 源
# rpm -ivh http://nginx.org/packages/CentOS/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
# yum -y install nginx
5. 创建 yum 源网站 (http://content.example.com) 配置文件
# vi /etc/nginx/conf.d/content.example.com.conf
server {
listen 80;
server_name content.example.com;
access_log /var/log/nginx/content.example.com.access.log combined;
location / {
root /content;
index index.html index.htm;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
6. 添加 DNS 记录到 /etc/hosts 文件
# echo “192.168.136.254 content.example.com” >> /etc/hosts
7. 开通防火墙
# firewall-cmd –permanent –add-service http
# firewall-cmd –reload
8. 修改网站目录 SELinux 类型
# chcon -t public_content_t -R /content/
9. 设置 nginx 服务开机自启动,并启动 nginx 服务
# systemctl enable nginx
# systemctl start nginx
10. 创建 repo 文件
# vi /etc/yum.repos.d/rhel-dvd.repo
[rhel-dvd]
name=remote ipa copy of dvd
baseurl=http://content.example.com/rhel7.1/x86_64/dvd
gpgcheck=0
enabled=1
11. 生成 repo cache,用来测试新 yum 源是否生效
# yum makecache
更多 YUM 相关教程见以下内容:
RedHat 6.2 Linux 修改 yum 源免费使用 CentOS 源 http://www.linuxidc.com/Linux/2013-07/87383.htm
配置 EPEL YUM 源 http://www.linuxidc.com/Linux/2012-10/71850.htm
Redhat 本地 yum 源配置 http://www.linuxidc.com/Linux/2012-11/75127.htm
yum 的配置文件说明 http://www.linuxidc.com/Linux/2013-04/83298.htm
RedHat 6.1 下安装 yum(图文) http://www.linuxidc.com/Linux/2013-06/86535.htm
YUM 安装及清理 http://www.linuxidc.com/Linux/2013-07/87163.htm
CentOS 6.4 上搭建 yum 本地源 http://www.linuxidc.com/Linux/2014-07/104533.htm
更多 RedHat 相关信息见RedHat 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=10
本文永久更新链接地址:http://www.linuxidc.com/Linux/2015-12/125905.htm