yum服务器部署
1.修改yum.conf配置文件
cachedir=/var/cache/yum/$basearch/$releasever
#安装完后保存软件包
keepcache=1
#安装完后删除软件包
#keepcache=0
扩展:下载软件不安装
yumdownloader pcre-devel openssl-devel # 只下载软件不安装,作为忘记开启 YUM 缓存的补救手段
2.下载创建yum仓库的软件包,这个命令用来下载yum仓库,用来安装
yum install -y createrepo
3.下载nginx(官方源安装)
yum install -y nginx
4.下载软件,识别优先级软件包
yum install -y yum-plugin-priorities.noarch
5.随便下载一些软件产生软件包
mkdir /yum -p
cd /var/cache/yum/x86_64/... (把里面的包 放到/yum)
6.编写配置文件
cat yum.conf
server {
listen 80;
server_name www.yum.com;
autoindex on;
location / {
root /yum;
index index.html index.htm;
}
}
7.启动服务
systemctl start nginx
systemctl enable nginx
8.浏览器打开 www.yum.com (看一下,然并卵)
9.创建仓库
createrepo /yum
- 看 /yum目录是否有 repodata这个目录,有代表创建成功,反之
服务端定制rpm包
可以灵活的存放安装位置
1.定制rpm nginx包准备工作
创建存放目录
mkdir -p /service/tools
创建软件存放目录
mkdir -p /application
进入存放目录
cd /service/tools
下载软件解压
wget http://nginx.org/download/nginx-1.16.0.tar.gz
tar xfn nginx-1.16.0.tar.gz
配置 nginx
cd nginx-1.16.0
./configure --prefix=/application/nginx-1.16 --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module
编译配置
make && make install
2.定制rpm包
定制rpm包 安装 ruby 模块
yum -y install ruby rubygems ruby-devel
查看当前源:
gem source list
添加国内源
gem sources -a http://mirrors.aliyun.com/rubygems/
移除本地源
gem sources --remove https://rubygems.org/
查看当前源
gem source list
安装 FPM 工具
gem install fpm
编写创建 nginx 的 rpm 包要执行的脚本
vim nginx_rpm.sh
#!/bin/bash
useradd -u 1010 -M -s /sbin/nologin www
通过 fpm 命令打包 rpm
fpm -s dir -t rpm -n nginx -v 1.160.0 -d 'pcre-devel,openssl-devel' --post-install /service/scripts/nginx_rpm.sh -f /application/nginx-1.16/
复制/yum里
mv /application/nginx-1.16.rpm /yum
更新索引
createrepo -pdo /yum/ /yum/ 或
createrepo /yum 或
createrepo --update /yum 都可以实现
客户端部署
1.下载优先级软件
yum install -y yum-plugin-priorities.noarch
- 编写local.repo文件,让用户下载软件时优先走本地源
vim local.repo
[local]
name=local
baseurl=http://10.0.0.61/
enabled=1
gpgcheck=0
priority=1
3.把其他源文件写priority=2 降低优先级或者直接删除其他源文件(推荐客户端只保存本地源文件)
4.测试是否成功
安装依赖nginx运行的依赖
yum install -y pcre-devel openssl-devel
清除缓存
yum clean all
下载nginx
yum install -y nginx
下载别的软件
yum install -y cowsay
未经博主允许,不得转载