linux 最简便yum仓库安装
yum服务端
#!/bin/bash
sed -i 's#keepcache=0#keepcache=1#g' /etc/yum.conf &&\
yum install -y pcre-devel openssl-devel
mkdir -p /server/tools &&\
cd /server/tools &&\
wget http://nginx.org/download/nginx-1.16.0.tar.gz &&\
tar xf nginx-1.16.0.tar.gz &&\
cd nginx-1.16.0/ &&\
mkdir /application &&\
useradd www -s /sbin/nologin -M &&\
./configure --user=www --group=www --prefix=/application/nginx-1.16.0 --with-http_stub_status_module --with-http_ssl_module --with-pcre &&\
make && make install &&\
ln -s /application/nginx-1.16.0/ /application/nginx &&\
/application/nginx/sbin/nginx &&\
lsof -i:80
kill nginx
yum -y install ruby rubygems ruby-devel &&\
yum install -y rpm-build &&\
yum install -y gcc &&\
gem sources -a http://mirrors.aliyun.com/rubygems/ &&\
gem sources --remove https://rubygems.org/ &&\
gem source list &&\
gem install fpm &&\
`cat >/server/scripts/nginx_rpm.sh<<EOF
useradd www -M -s /sbin/nologin
ln -s /application/nginx-1.10.2/ /application/nginx
EOF`
fpm -s dir -t rpm -n nginx -v 1.16.0 -d 'pcre-devel,openssl-devel' --post-install /server/scripts/nginx_rpm.sh -f /application/nginx-1.16.0/
# 创建仓库目录
mkdir /application/yum/centos7/x86_64 -p
#将生成的nginx? rpm包放到该目录
mv nginx-1.16.0-1.x86_64.rpm /application/yum/centos6/x86_64/
yum -y install createrepo
createrepo -pdo /application/yum/centos7/x86_64/ /application/yum/centos7/x86_64/
`cat >/application/nginx/conf/nginx.conf<<EOF
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root /application/yum/centos7/x86_64/;
autoindex on; ##开启目录
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
EOF`
/application/nginx/sbin/nginx -t
/application/nginx/sbin/nginx
find /var/cache/yum/x86_64/7 -type f -name "*.rpm"|xargs -i cp {} /application/yum/centos7/x86_64
#提示:每加入一个rpm包就要执行一下如下命令,用来更新索引
createrepo --update /application/yum/centos7/x86_64/
配置客户端
mkdir /etc/yum.repos.d/jyt
mv /etc/yum.repos.d/* /etc/yum.repos.d/jyt/
cat > /etc/yum.repos.d/local.repo << eof
[local]
name=Server
baseurl=http://10.0.0.222
enable=1
gpgcheck=0
eof
yum clean all
#指定指定使用local源,此命令重启linux系统失效:
yum --enablerepo=local --disablerepo=base,extras,updates,epel list
菜鸟9528号,请求开炮。