nginx搭建本地yum源
一. 简介
上个教程制作了一个简单的rpm,这儿介绍下本地源的搭建,将它发布上去。
二. 安装
创建文件夹
mkdir -p /vps/hosts/mirrors/centos/7/siyou325/x86_64/Packages/
将上个教程生成的helloworld-1.0.0-1.el7.x86_64.rpm拷贝到这个文件夹下,然后执行下面命令更新本地源
yum -y install createrepo
createrepo --update /vps/hosts/mirrors/centos/7/siyou325/x86_64/
三. nginx配置
下面配置nginx
# mirrors.wangbin.io;
server {
listen 50443 ssl http2;
listen [::]:50443 ssl http2;
server_name mirrors.wangbin.io;
access_log logs/wangbin.io/access-mirrors.wangbin.io.log siyou325;
error_log logs/wangbin.io/error.log;
ssl_certificate /vps/certificate/acme/*.wangbin.io/fullchain.cer;
ssl_certificate_key /vps/certificate/acme/*.wangbin.io/*.wangbin.io.key;
ssl_trusted_certificate /vps/certificate/acme/*.wangbin.io/fullchain.cer;
root /vps/hosts/mirrors;
index index.html index.htm index.php;
location ~ ^(.*)/$ {
charset utf-8;
autoindex on;
autoindex_localtime on; #显示的文件时间为文件的服务器时间
autoindex_exact_size off; #改为off后,显示出文件的大概大小,单位是kB或者MB或者GB
}
# 禁止访问.svn目录,防止svn信息泄漏,必加项
location ~ ^(.*)\/\.svn\/ {
deny all;
}
}
完成后执行
nginx -t
nginx -s reload
nginx就配置完成啦
四. CentOS-siyou325.repo
CentOS-siyou325.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[siyou325]
name=CentOS-$releasever - siyou325
baseurl=http://mirrors.siyou325.com/centos/$releasever/siyou325/$basearch/
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
用CentOS-siyou325.repo替换/etc/yum.repos.d/CentOS-siyou325.repo,命令如下
mv CentOS-siyou325.repo /etc/yum.repos.d/CentOS-siyou325.repo
完成后执行
yum clean all
yum makecache
五. 结尾
就这样^_^