1.环境整理:关闭防火墙、selinux
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
2.参数IP:192.168.241.16,nginx:1.16
A.部署安装nginx
在192.168.241.16安装nginx,提供http访问
1.源码安装nginx
[root@localhost ~]# yum -y install gcc make zlib-devel pcre pcre-devel openssl-devel
[root@localhost ~]# mkdir /soft && cd /soft
[root@localhost soft ~]# wget http://nginx.org/download/nginx-1.16.1.tar.gz
[root@localhost soft ~]# tar xzvf nginx-1.16.1.tar.gz && cd nginx-1.16.1
[root@localhost nginx-1.16.1]# ./configure --prefix=/usr/local/nginx
[root@localhost nginx-1.16.1]# make
[root@localhost nginx-1.16.1]# make install
2.启动
[root@localhost ~]# /usr/local/nginx/sbin/nginx
3.查看nginx是否工作 http://192.168.241.16
B.制作生成私有yum仓库
1.安装repo索引文件工具
[root@localhost ~]# yum install -y createrepo
2.创建yum仓库工作目录packages目录存放rpm包,repo目录存放yum仓库repo源文件
[root@localhost ~]# mkdir -p /data/{packages,repo}
3.上传rpm包至packages目录
4.生成yum仓库repo源文件,提供给客户端,远程下载直接使用baseurl为nginx供的http服务地址
[root@localhost ~]# cat >/data/repo/local.repo<<EOF
[Local_yum]
name='Local_yum'
baseurl=http://192.168.241.16
enabled=1
gpgcheck=0
EOF
5.创建repo索引
[root@localhost ~]# createrepo /data
C.修改nginx目录html默认工作目录
1.将nginx的/usr/local/nginx/html默认工作目录修改为/data,开启目录浏览
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
修改
location / {
root html;
index index.html index.htm;
}
如下
location / {
root /data;
autoindex on; //开启目录浏览
index index.html index.htm;
}
2.重启nginx
[root@localhost ~]# /usr/local/nginx/sbin/nginx -s reload
3.查看nginx是否工作
[root@localhost ~]# ps aux | grep nginx
4.查看nginx的工作端口
[root@localhost ~]# ss -ntpl | grep nginx
D.以http方式访问yum仓库地址
http://192.168.241.16
E.客户端使用私有yum仓库
1.下载repo仓库源文件至/etc/yum.repos.d/目录下
[root@localhost ~]# rpm -qa | grep wget || yum install wget -y
[root@localhost ~]# wget -O /etc/yum.repos.d/local.repo http://192.168.241.16/repo/local.repo
2.清理yum缓存、查看yum源
[root@localhost ~]# yum clean all
[root@localhost ~]# yum repolist
3.安装yum仓库源中的包
[root@localhost ~]# yum install 软件名称 -y