yum -y install gcc automake autoconf libtool make gcc-c++
cd /usr/local/src
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.gz
tar -zxvf pcre-8.37.tar.gz
cd pcre-8.34
./configure
make
make install
cd /usr/local/src
wget http://zlib.NET/zlib-1.2.8.tar.gz
tar -zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure
make
make install
cd /usr/local/src
wget http://nginx.org/download/nginx-1.12.2.tar.gz
cd nginx-1.12.2
yum -y install openssl openssl-devel
./configure --with-http_stub_status_module --with-http_ssl_module
user root;
worker_processes 2;
error_log logs/error.log;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type Application/octet-stream;
client_max_body_size 20m;
log_format mAIn '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
keepalive_timeout 65;
#gzip on;
server {
listen 443 ssl;
server_name repo.example.com;
ssl on;
ssl_certificate cert/789615.pem;
ssl_certificate_key cert/789615.key;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
root /opt/repo;
autoindex on;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
创建存放同步源的目录(以centos7为例)
mkdir -p /opt/repo/centos/7/os/x86_64/
mkdir -p /opt/repo/centos/7/extras/x86_64/
mkdir -p /opt/repo/centos/7/updates/x86_64/
mkdir -p /opt/repo/epel/7/x86_64/
使用rsync工具同步互联网上的源文件
rsync -av rsync://mirrors.ustc.edu.cn/centos/7/os/x86_64/ /opt/repo/centos/7/os/x86_64/
rsync -av rsync://mirrors.ustc.edu.cn/centos/7/extras/x86_64/ /opt/repo/centos/7/extras/x86_64/
rsync -av rsync://mirrors.ustc.edu.cn/centos/7/updates/x86_64/ /opt/repo/centos/7/updates/x86_64/
rsync -av --exclude=debug rsync://mirrors.ustc.edu.cn/epel/7/x86_64/ /opt/repo/epel/7/x86_64/
5.创建repo文件
[base]
name=CentOS-$releasever - Base
baseurl=https://repo.example.com/centos/$releasever/os/$basearch/
enable=1
gpgcheck=0
[updates]
name=CentOS-$releasever - Updates
baseurl=https://repo.example.com/centos/$releasever/updates/$basearch/
enable=1
gpgcheck=0
[extras]
name=CentOS-$releasever - Extras
baseurl=https://repo.example.com/centos/$releasever/extras/$basearch/
enable=1
gpgcheck=0
[epel]
name=epel-$releasever
baseurl=https://repo.example.com/epel/$releasever/$basearch/
enable=1
gpgcheck=0
至此,本地yum源服务器搭建完成,内网中的其他服务器可以通过这台本地yum源服务器来安装部署和更新软件了,在考虑安全的前提下,极大地提升了我们的工作效率。今天的分享,你学会了吗?