背景,因为公司 给了 几台 服务器,让我安装测试环境,但是服务器不能上外网,
也不能使用yum源,而且 服务器系统 太过精简,什么 vim,wget,curl都没有
。所以 打算 在虚拟机上 自建一个 yum 源,并通过 http 服务,对虚拟机提供服务
环境准备
nginx 服务器
nginx 上的 虚拟服务器配置是
server{ listen 80 default_server; listen [::]:80 default_server; server_name _; root /opt/yum/centos/7/os/; include /etc/nginx/default.d/*.conf;
location / { autoindex on; autoindex_exact_size off; autoindex_localtime on; index index.html; }
error_page 404 /404.html; location = /40x.html{ }
error_page 500 502 503 504 /50x.html;
location = /50x.html{ }
} |
现在 正式开始
1 创建 索引
mkdir /opt/yum/centos/7/os/
createrepo /opt/yum/centos/7/os
同步阿里云 rpm 包
1 设置阿里云镜像为本地 yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
2 同步 阿里云仓库
reposync -r base -p /opt/yum/centos/7/os/
3 更新索引
createrepo /opt/yum/centos/7/os/base/Packages/
每加入一个 rpm 包 就要更新
createrepo –update /opt/yum/centos/7/os/base/Packages/
4 清理缓存数据
yum clean all && yum makecache
5 vim /etc/yum.repos.d/shendu-7.repo内容如下
[shendu] name = centos-shendu baseurl=http://172.16.96.71:8888/base/Packages/ enabled=1 gpgcheck=0
|
错误:
第一次建的时候,
报了 nothing to do 错误
原来 阿里云 下载 的 rpm 包 不完整
注意:
要在 createrepo /opt/yum/centos/7/os/base/Packages/ 生成 xml的时候保证成功,不然会错误
Wmware 将 服务器的端口 映射 到 本地
wmware 界面选择 编辑, 虚拟网络编辑
-à nat 设置
à 添加端口转发
本地访问