zoukankan      html  css  js  c++  java
  • 搭建本地yum源

    服务器端配置

    #!/bin/bash
    #rsync 一键脚本 可以直接用vim 创建一个123.sh文件然后把这里面的全部复制到里面直接执行以下就可以了
    #nginx-install
    NG_DIR="/usr/local/nginx"
    NG_CS="--user=www --group=www --with-http_stub_status_module --with-http_ssl_module"
    yum install wget gcc pcre pcre-devel openssl-devel openssl gzip createrepo make cmake zlib-devel tar lrzsz -y
    wget -c http://nginx.org/download/nginx-1.14.0.tar.gz
    tar -xzf nginx-1.14.0.tar.gz
    cd nginx-1.14.0
    useradd www -s /sbin/nologin
    ./configure  --prefix=$NG_DIR $NG_CS
    make
    make install
    echo $?
    echo "
        [Unit]
    Description=nginx service
    After=network.target
       
    [Service]
    Type=forking 
    ExecStart=/usr/local/nginx/sbin/nginx
    ExecReload=/usr/local/nginx/sbin/nginx -s reload
    ExecStop=/usr/local/nginx/sbin/nginx -s quit
    PrivateTmp=true 
       
    [Install] 
    WantedBy=multi-user.target
    ">/lib/systemd/system/nginx.service
    
    echo "
    worker_processes 2;
    worker_rlimit_nofile 65535;
    worker_cpu_affinity 1000 0100;
    events {
    worker_connections 15000;
    }
    http {
            include mime.types;
            default_type application/octet-stream;
            sendfile on;
            keepalive_timeout 65;
            #include  /usr/local/nginx/conf.d/*.conf;
    server {
             listen                  80;
     
             root                    /var/ftp/pub/;
            # access_log              /var/log/nginx/access.log  main;
     
             location / { 
             autoindex on; 
             autoindex_exact_size off; 
             autoindex_localtime on; 
        }
     
    }   
    }" >/usr/local/nginx/conf/nginx.conf
    #设置为nginx开机自启动,并设置为开机自启动
    systemctl start nginx.service
    systemctl enable nginx.service
    ss -ntl
    #安装vsftpd
    yum install vsftpd -y
    systemctl enable vsftpd
    systemctl start vsftpd
    #创建yum源存放目录
    mkdir -p /var/ftp/pub/epel/7/
    mkdir -p /var/ftp/pub/centos/7/os/x86_64/
    mkdir -p /var/ftp/pub/centos/7/updates/x86_64/
    mkdir -p /var/ftp/pub/centos/7/extras/x86_64/
    mkdir -p /var/ftp/pub/centos/7/centosplus/x86_64/
    echo "
    SRPMS
    aarch64
    ppc64
    repodata
    EFI
    LiveOS
    CentOS_BuildTag
    EULA
    GPL
    drpms
    " >/var/ftp/pub/exclude.list
    echo "
    
    #epel
    rsync -avz --exclude-from=/var/ftp/pub/exclude.list rsync://mirrors.tuna.tsinghua.edu.cn/epel/7/ /var/ftp/pub/epel/7/
    createrepo /var/ftp/pub/epel/7/
     
    #centos7-base
    rsync -avz --exclude-from=/var/ftp/pub/exclude.list rsync://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/ /var/ftp/pub/centos/7/os/x86_64/
    createrepo /var/ftp/pub/centos/7/os/x86_64/
     
    #centos7-updates
    rsync -avz --exclude-from=/var/ftp/pub/exclude.list rsync://mirrors.tuna.tsinghua.edu.cn/centos/7/updates/x86_64/ /var/ftp/pub/centos/7/updates/x86_64/
    createrepo /var/ftp/pub/centos/7/updates/x86_64/
     
    #centos7-extras
    rsync -avz --exclude-from=/var/ftp/pub/exclude.list rsync://mirrors.tuna.tsinghua.edu.cn/centos/7/extras/x86_64/ /var/ftp/pub/centos/7/extras/x86_64/
    createrepo /var/ftp/pub/centos/7/extras/x86_64/
     
    #centos7-centosplus
    rsync -avz --exclude-from=/var/ftp/pub/exclude.list rsync://mirrors.tuna.tsinghua.edu.cn/centos/7/centosplus/x86_64/ /var/ftp/pub/centos/7/centosplus/x86_64/
    createrepo /var/ftp/pub/centos/7/centosplus/x86_64/
    " >/var/ftp/pub/centos7-rsync.sh
    #这条命令可以做一个定时任务,每星期1的凌晨2点定时同步一下
    sh /var/ftp/pub/centos7-rsync.sh
    

    客户端操作

    cd /etc/yum.repos.d/
    mkdir bak
    mv *.repo bak/
    vim /etc/yum.repos.d/centos7.repo
    
    //输入以下内容
    [base]
    name=Base
    baseurl=http://192.168.123.57/centos/7/os/x86_64/
    gpgcheck=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    
    [epel]
    name=epel
    baseurl=http://192.168.123.57/epel/7/
    gpgcheck=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    
    #released updates 
    [updates]
    name=Updates
    baseurl=http://192.168.123.57/centos/7/updates/x86_64/
    gpgcheck=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    
    #additional packages that may be useful
    [extras]
    name=Extras
    baseurl=http://192.168.123.57/centos/7/extras/x86_64/
    gpgcheck=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    
    #additional packages that extend functionality of existing packages
    [centosplus]
    name=Plus
    baseurl=http://192.168.123.57/centos/7/centosplus/x86_64/
    gpgcheck=0
    enabled=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS
    
    yum clean all
    yum makecache
    
  • 相关阅读:
    apache2+django+virtualenv 服务器部署实战
    从 relu 的多种实现来看 torch.nn 与 torch.nn.functional 的区别与联系
    Causal Corpus 事件因果关系语料统计
    Event StoryLine Corpus 论文阅读
    哈工大计算机网络Week2-网络应用数据交换
    哈工大计算机网络Week3-传输层
    哈工大计算机网络Week1-网络应用
    哈工大计算机网络Week0-概述
    python爬虫入门
    对scanner.close方法的误解以及无法补救的错误
  • 原文地址:https://www.cnblogs.com/yizhangheka/p/12636315.html
Copyright © 2011-2022 走看看