服务器端配置
#!/bin/bash
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 vim createrepo make cmake zlib-devel tar rsync 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
systemctl start nginx.service
systemctl enable nginx.service
ss -ntl
yum install vsftpd -y
systemctl enable vsftpd
systemctl start vsftpd
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
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
[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
[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
[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
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux glibc自带哈希表的用例及性能测试
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
· 现代计算机视觉入门之:什么是图片特征编码
· 手把手教你在本地部署DeepSeek R1,搭建web-ui ,建议收藏!
· Spring AI + Ollama 实现 deepseek-r1 的API服务和调用
· 数据库服务器 SQL Server 版本升级公告
· 程序员常用高效实用工具推荐,办公效率提升利器!
· C#/.NET/.NET Core技术前沿周刊 | 第 23 期(2025年1.20-1.26)