• 一键安装_nginx 并搭建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;
    #server_name mirror.t.com;

    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 "
    createrepo /var/ftp/pub/epel/7/

    #centos7-base
    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/ft
    p/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

  • 相关阅读:
    每日日报2021.4.14
    每日日报2021.4.13
    每日日报2021.4.12
    每日日报2021.4.9
    每日日报2021.4.8
    每日日报2021.4.7
    每日日报2021.4.6
    每日日报2021 4/22
    每日日报2021 4/21
    每日日报2021 4/20
  • 原文地址:https://www.cnblogs.com/zhanghongqi/p/11888925.html
Copyright © 2020-2023  润新知