1.创建目录安装软件程序

1.在/root路径下创建123.sh文件,把此文件复制到123.sh里,  sh 123.sh
2.首选安装nginx,作为web展示
3.强力清除老版本残留
rpm -e nginx --nodeps
rm -rf  /etc/nginx
4.开始安装
yum install -y nginx

2.配置文件的编辑

cat > /etc/nginx/nginx.conf << EOF
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {worker_connections 1024;}
http {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  /var/log/nginx/access.log  main;
    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;
    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;
    server{
    listen              80;
    root                /var/ftp/pub/;
    autoindex on;}      }
EOF

#安装vsftpd
yum install  vsftpd -y
#启动自启nginx,ftp
systemctl start nginx
systemctl enable nginx
systemctl start vsftpd
systemctl enable 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/
#把不同步的yum源写入到排除文件
mkdir -p /var/ftp/pub/
cat > /var/ftp/pub/exclude.list <<EOF
SRPMS
aarch64
ppc64
ppc64le
debug
repodata
EFI
LiveOS
images
isolinux
CentOS_BuildTag
EULA
GPL
RPM-GPG-KEY-CentOS-7
RPM-GPG-KEY-CentOS-Testing-7
drpms
EOF
#这里写一个同步清华大学源的脚本
cat >  /var/ftp/pub/centos7-rsync.sh <<EOF
#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/

EOF

3.最后一步,执行脚本同步

sh /var/ftp/pub/centos7-rsync.sh

4.做一个定时更新yum源的任务(可做可不做)

echo "#每天4点更新yum源
00 04 * * *  /usr/bin/sh    /var/ftp/pub/centos7-rsync.sh  &> /dev/null" >> /var/spool/cron/root

 
 
 

最新文章

  1. MySQL基础笔记
  2. heightcharts
  3. AD域内DNS服务器如何解析公网域名
  4. Unity5中的MetaPass
  5. 自定义不等高cell—storyBoard或xib自定义不等高cell
  6. 【转】CDH5.x升级
  7. codeforces 374A Inna and Pink Pony 解题报告
  8. Androidi性能优化之高效使用内存
  9. json校验
  10. [转]论window和Linux之长短
  11. Dynamic - ExpandoObject学习心得
  12. python2.x urllib2和urllib的使用
  13. 功率W与dBm的对照表及关系(转)
  14. Jenkis Editable Email Notification Plugin 使用介绍
  15. Java 第三周总结
  16. The man Command
  17. bzoj 1082: [SCOI2005]栅栏
  18. 如何 DataTable格式转换json格式
  19. 如何快速地开发一个微信小程序
  20. docker image 详解

热门文章

  1. Ant 环境安装
  2. LeetCode 56,区间合并问题
  3. 【python】numpy库和matplotlib库学习笔记
  4. 迁移WPF项目到.NET CORE
  5. centos系统克隆
  6. MYSQL连接端口被占引入文件路径错误
  7. Linux内核驱动学习(八)GPIO驱动模拟输出PWM
  8. Ubuntu 18.04 新系统 允许root远程登录
  9. 【漫画】JAVA并发编程 如何解决原子性问题
  10. python之邮件发送自动化